• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Basic SQL command will not return object

#1
I am trying to run a very basic query, and I can not get an object to return.. Other functions (using the same database) in this model work just fine, I am querying a MS-SQL database

PHP Code:
function tmp2()
 {
 echo 
'CodeIgniter: '.CI_VERSION.'<br>';
 
$lines $this->db->select('*')->from('Util_TMP_Calibrate')->get();
 if(
is_object($lines)){ 
           
$nr=$lines->num_rows(); 
 } else { 
           echo 
'not object'
           
$nr=0
 } 

Code:
CodeIgniter: 3.1.6
not object
SELECT * FROM "Util_TMP_Calibrate"
Reply

#2
@Juicepig,

Any plans to upgrade CI?

Also, have you troubleshooted the $lines variable to see what value it is receiving? var_dump?

Maybe this can help ( https://codeigniter.com/user_guide/datab...ry-results ).
Reply

#3
(02-12-2019, 09:15 AM)php_rocs Wrote: @Juicepig,

Any plans to upgrade CI?

Also, have you troubleshooted the $lines variable to see what value it is receiving? var_dump?

Maybe this can help ( https://codeigniter.com/user_guide/datab...ry-results ).

var_dump($lines) returns bool(false) 

Table name changed for troubleshooting.. Still returns false when the code is simplified to: 

PHP Code:
        $lines $this->db->query("select * from Util_TMP_Cal");
        echo 
var_dump($lines).'<br>'


Still working on an upgrade from a year ago at the moment (see https://forum.codeigniter.com/thread-69978.html)
Reply

#4
@Juicepig,

Are you sure that your query is returning a value? Based on the value of $lines I would say it is not returning any values. Have you run your query in MySQL directly to make sure that it works?
Reply

#5
(02-12-2019, 09:41 AM)php_rocs Wrote: @Juicepig,

Are you sure that your query is returning a value?  Based on the value of $lines I would say it is not returning any values.  Have you run your query in MySQL directly to make sure that it works?

Yes, i think there is an issue with the data - for instance if I just select some columns, i get a valid result.  Not sure why * will not work (* works in the SQL console)

PHP Code:
        $lines $this->db->select('hasWater,hasSewer')->from('UTIL_TMP_CALIB')->get();
        echo 
var_dump($lines); 
Reply

#6
@Juicepig,

The table name in all three post are spelled different.

1st post: Util_TMP_Calibrate
2nd post: Util_TMP_Cal
3rd post: UTIL_TMP_CALIB

Also, make sure that the table name is not case sensitive. That would definitely cause problems. For MySQL, I always use lower case for table names and fields.
Reply

#7
(02-12-2019, 03:38 PM)php_rocs Wrote: @Juicepig,

The table name in all three post are spelled different.

1st post: Util_TMP_Calibrate
2nd post: Util_TMP_Cal
3rd post: UTIL_TMP_CALIB

Also, make sure that the table name is not case sensitive.  That would definitely cause problems.  For MySQL, I always use lower case for table names and fields.


Yes, that was due to ongoing troubleshooting.  At the time the code was run, the capitalization and table names were completely valid.


The Solution appears to be an increase the SQL memory buffer in php.ini as follows.  If there were more then a thousand entries or so, the results would be false, rather then a valid object.

Code:
memory_limit = 512M
client_buffer_max_kb_size = '50240'
sqlsrv.ClientBufferMaxKBSize = 50240
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.