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:
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 :
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
– novic
This answers your question? query in PHP is empty but in SQL Server it works
– novic
Because of the insistence on doing wrong?
– novic
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.
– LEANDRO DA SILVA
In his model,
$this->db->query($sql)
is returningfalse
, which indicates that SQL is failing. What happens if you run it directly in the database?– Woss
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!
– novic
@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
– novic
@Woss is running correctly, it brings right values, novic I edited this as you explained and is returning the same error.
– LEANDRO DA SILVA
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.– Augusto Vasques
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)
– LEANDRO DA SILVA
There is no way to show, the error is elsewhere because the question does not show enough information to point out the culprit.
– Augusto Vasques
has the controller, model, and output, which most accurately?
– LEANDRO DA SILVA
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.
– Augusto Vasques
I did in pure PHP, it brought me correctly the same query! using fetchAlll
– LEANDRO DA SILVA
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.
– Augusto Vasques
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
– LEANDRO DA SILVA
Then I can’t help you, just inspecting your system. At least you already have a course.
– Augusto Vasques
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.
– Augusto Vasques