Welcome Guest, Not a member yet? Register   Sign In
SQL Server Not Returning Data
#1

Hi,

I have a model that has a simple query. Here's the code:

PHP Code:
$this->db->select("*")
 ->
from("vmb_TempsAndTolerances")
 ->
where("idgrades"$idgrade)
 ->
where("idtypes"$idtype);
 
 
$query $this->db->get();
 
$result_array $query->result_array

I have profile turned on and this is the query that is generated by this:

Code:
SELECT *
FROM vmb_TempsAndTolerances
WHERE idgrades =  'C19B5EC2-FBCB-4761-9ACE-43297F0876B7'
AND idtypes =  'BFB30716-EA84-4E34-9A81-1A07EAF37AD5'  

When I copy this into SQL Server Management Studio, I get information returned. Yet, $result_array is coming back empty.

I var_dumped both $query and $result_array and here is what I get from that.

Code:
object(CI_DB_sqlsrv_result)[16]
 public 'conn_id' => resource(29, SQL Server Connection)
 public 'result_id' => resource(39, SQL Server Statement)
 public 'result_array' =>
   array (size=0)
     empty
 public 'result_object' =>
   array (size=0)
     empty
 public 'custom_result_object' =>
   array (size=0)
     empty
 public 'current_row' => int 0
 public 'num_rows' => int 4
 public 'row_data' => null

array (size=0)
 empty

No errors are returned. I have many other queries that work just fine.

Any ideas at this point are appreciated.

Thanks
Reply
#2

Did you try $query->result_array() instead of $query->result_array?

Do you have autoinit set to true in your database config (or, if not, are you initializing your database connection)?
Reply
#3

(This post was last modified: 06-09-2015, 01:18 PM by Blair2004.)

Actually result_array it's a method and not a property
NexoPOS 2.6.2 available on CodeCanyon.
Reply
#4

(06-09-2015, 12:26 PM)mwhitney Wrote: Did you try $query->result_array() instead of $query->result_array?

Do you have autoinit set to true in your database config (or, if not, are you initializing your database connection)?

It was result_array(). Don't ask me how I missed that. I must have looked at that piece of code 1000 times!

I wonder why PHP didn't kick that out as an error?

THANKS for the assist!
Reply
#5

(06-09-2015, 02:14 PM)bazianm Wrote:
(06-09-2015, 12:26 PM)mwhitney Wrote: Did you try $query->result_array() instead of $query->result_array?

Do you have autoinit set to true in your database config (or, if not, are you initializing your database connection)?

It was result_array(). Don't ask me how I missed that. I must have looked at that piece of code 1000 times!

I wonder why PHP didn't kick that out as an error?

THANKS for the assist!

result_array is also a public property in the db library, but it doesn't necessarily have a value until you call one of the methods which populates it (like result_array()).
Reply
#6

(06-10-2015, 06:32 AM)mwhitney Wrote:
(06-09-2015, 02:14 PM)bazianm Wrote:
(06-09-2015, 12:26 PM)mwhitney Wrote: Did you try $query->result_array() instead of $query->result_array?

Do you have autoinit set to true in your database config (or, if not, are you initializing your database connection)?

It was result_array(). Don't ask me how I missed that. I must have looked at that piece of code 1000 times!

I wonder why PHP didn't kick that out as an error?

THANKS for the assist!

result_array is also a public property in the db library, but it doesn't necessarily have a value until you call one of the methods which populates it (like result_array()).

Oh OUCH! That's an error I will try not to make again. Cost me the better part of a day and a half of time.

Thanks!
Reply
#7

(This post was last modified: 06-12-2015, 11:45 AM by lexxtoronto.)

>>I wonder why PHP didn't kick that out as an error?

Is it in production mode? Errors will be suppressed. I also had a similar problem with db queries and it won't show any errors, but then I realized they were db generated errors and I wasnt catching them.
Do the one thing you think you cannot do. Fail at it. Try again. Do better the second time. The only people who never tumble are those who never mount the high wire.
Reply
#8

4 rows seems to be returned, use result_array() instead, since $result_array is empty
NexoPOS 2.6.2 available on CodeCanyon.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB