A
A
Anton Boyarshinov2017-09-27 18:54:47
CodeIgniter
Anton Boyarshinov, 2017-09-27 18:54:47

How to get return value from procedure in CodeIgniter?

There is a procedure that returns a number when executed.
In CI I'm trying to get the value like this:

$str ="DECLARE	@ret int ".
"exec @ret = [my_proc] ".
"@UserID = '".$this->getID()."', ". 
"SELECT	'val' = @ret"; 
$result = $this->db->query($str); 
return    $result->result('val');

as a result, return returns an empty value because $result is null
However, if you just run it in ssms, everything works OK, it returns 1 column with 1 row with the value I need.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
synapse_people, 2017-09-27
@synapse_people

look at the row method
call it like this $result->row('val')

E
Egor, 2017-09-28
@egormmm

There is some error in the request that is sent to the server.
Look at the query that was formed in the line.
Try it without codeigniter.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question