Welcome Guest, Not a member yet? Register   Sign In
Basic SQL command will not return object
#1

(This post was last modified: 02-12-2019, 07:38 AM by Juicepig.)

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

(This post was last modified: 02-12-2019, 08:17 AM by php_rocs.)

@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

(This post was last modified: 02-12-2019, 08:41 AM by Juicepig.)

(02-12-2019, 08: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, 08: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

(This post was last modified: 02-19-2019, 08:28 AM by Juicepig.)

(02-12-2019, 02: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




Theme © iAndrew 2016 - Forum software by © MyBB