Jump to content
Fórum Script Brasil
  • 0

Metodo não retorna valor


nsouza

Question

Colegas,

o return do metodo abaixo não esta funcionando, se eu der um

print_r($object)
antes dele, mostra o resultado do array, mas se eu der o
print_r($object)
depois, ele não mostra nada. Pode me ajudar?
public function load($id)         
        { 
            
                //instacia a instrução de select
                $sql = new TSqlSelect();
                $sql->setEntity($this->getEntity());
                $sql->addColumn('*');
                
                //cria criterio de selecao baseado em ID
                $criteria = new TCriteria();
                $criteria->add(new TFilter('id', '=', $id));
                //define o criterio de selecao
                $sql->setCriteria($criteria);
                
            
                //obtem a transação ativa
                if ($conn = TTransaction::get())
                {
                    //cria a mensagem de log e executa a consulta
                    TTransaction::log($sql->getInstruction());
                    $result = $conn->Query($sql->getInstruction());
                    
                    //se retornou algum dado
                    if ($result) 
                    {
                        
                        
                        //retorna os dados em forma de objeto
                        $object = $result->fetchObject(get_class($this));
                                        
                        
                    }
                    
                    return  $object;        
                                            
                }
                else 
                {
                    //se não houver transacao retorna uma execçao
                throw new Exception('Não há transação ativa!!');
                
                }
                
                
        }//fim do metodo load

Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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
      149390
    • Total Posts
      645880
×
×
  • Create New...