Jump to content
Fórum Script Brasil
  • 0

erro: Undefined property: stdClass não fazendo pesquisa


betocardoso

Question

$this->db->select('usu.nome AS patrocinador');
            $this->db->from('usuarios AS usu');
            $this->db->join('rede AS rd', 'rd.id_patrocinador = usu.id', 'inner');
            $this->db->where('rd.id_patrocinador', $id);

            $patrocinador = $this->db->get();

            if($patrocinador->num_rows() > 0){

                $dados['patrocinador'] = $patrocinador->result();
            }

 

DA UM ERRO E NÃO FAZ A PESQUISA

 

NA VIEW TA ASSIM

<tr>
                                          <td>Patrocinador</td>
                                          <td><?php echo $usuario['usuario']->patrocinador;?></td>
                                        </tr>
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0
<?php
class tentativa {
    public $db;
    public function __construct(){
        $this->db=new PDO("mysql:host=localhost;dbname=astudy","root","");}
    public function teste($indice){
        $smt=$this->db->prepare('select nome from usuarios,rede where 
            usuarios.id=rede.id_patrocinador and id_patrocinador=:teste');
        $smt->bindParam(':teste',$indice);
        $smt->execute();
        return $smt->fetchObject();}}
$tentativa=new tentativa();
$patrocinador=$tentativa->teste(1);
?>
<div style="width:25%;margin:0 auto">
<table>
<tr><td>Patrocinador</td><td><?=$patrocinador->nome?>
</table>
</div>

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.1k
    • Total Posts
      651.9k
×
×
  • Create New...