Call to a Member Function result() on bool

Asked

Viewed 140 times

0

I’m trying to get results from a Stored Procedure in the CodeIgniter, in the bank brings the result normally but in the CodeIgniter brings that mistake:

inserir a descrição da imagem aqui

in my model is like this:

public function totalPassagens(array $array)
{
    $sql = "SET NOCOUNT ON exec whRelOSTotalizarResultadoAgendamento 3562, ?, ?, ?";
    $query = $this->db->query($sql);
    return $query->result();
}

and in my controller just to go out I did so:

$result = $this->posvendas->totalPassagens([getCodeLocal($local), 
      date('Y-m-01 00:00:00'), 
      date('Y-m-d 23:59:59')]); // Não esta retornando a consulta
echo '<prev>';
print_r($result);

If I take SET NOCOUNT ON from the front of the exec it does not from the error but does not bring me the expected result but an empty array, then I tested it in any file with the query sequinte :

try {
      $Conexao    = ConexaoTS::getConnection();
      $infoQuery  = $Conexao->query("SET NOCOUNT ON  EXEC 
       whRelOSTotalizarResultadoAgendamento 
       @CodigoEmpresa=3562, @CodigoLocal= ?, @DaDataAgenda= ?, 
     @AteDataAgenda= ?");
      
      $info       = $infoQuery->fetchAll();
    } catch (Exception $e) {
    
      echo $e->getMessage();
      exit;
    }
    
echo '<prev>';
print_r($info);

I did exactly the same query and the result was this :

inserir a descrição da imagem aqui

I mean, it brought the results, but in CodeIgniter brings me nothing, I tried to put result_array(), get(), result() but I’m taking the same error.

  • Why are you insisting the wrong way? It’s even a duplicate of your previous one

  • 2
  • 1

    Because of the insistence on doing wrong?

  • could delete the previous question but can help other people, created a new one to pass more information that may be useful. but as I said I did exactly as you said and the result is the same.

  • In his model, $this->db->query($sql) is returning false, which indicates that SQL is failing. What happens if you run it directly in the database?

  • 1

    Erase the question you’re right? Erase it on your own whim? the community here thinks different, I gave you a technical part that many err!

  • 2

    @Woss he is using paramentro param1 within SQL and that’s not how he does it ... I already wrote an answer to him on this question he keeps missing ... https://answall.com/questions/481138/query-no-php-vem-void-mas-no-sql-server-tem-result

  • @Woss is running correctly, it brings right values, novic I edited this as you explained and is returning the same error.

  • That mistake Call Member result on bool is common to occur when there are syntax errors in the query, result set returns false and the programmer does not perform any validation test in that result set and tries to use it anyway.

  • Could you explain to me what the right way would be? remembering that in own sql works and in that other test also, only in CI3 not working (I am PHP beginner)

  • There is no way to show, the error is elsewhere because the question does not show enough information to point out the culprit.

  • has the controller, model, and output, which most accurately?

  • The part of the code that generates the error because it’s not there. Try the same query in pure php if passing is probably a problem with Codeigniter, if you can also pass with sql driver.

  • 1

    I did in pure PHP, it brought me correctly the same query! using fetchAlll

  • The Igniter code is corrupted. Or misconfigured. Poorly installed. If you have access to the system you cannot be categorical, but it is in this direction.

  • I changed the system folder and still this giving error, downloaded again and put in the xampp, I believe it is difficult to be poorly installed since it is just run! Or just not this unstable

  • Then I can’t help you, just inspecting your system. At least you already have a course.

  • I did a quick search and the manual installation of Codeigniter is passive to generate conflicts. Installation by Composer is quieter yet can generate conflicts in case of update.

Show 13 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.