![]() |
simple_query() return...? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: simple_query() return...? (/showthread.php?tid=8015) |
simple_query() return...? - El Forum - 05-01-2008 [eluser]rvent[/eluser] Hello, I have this controller that takes the data from the user and inserts it into the DB. But i want to make sure that there is not other record like it so i have the following Controller: Code: function testDB() Model: Code: function isPart($part) the $bool is being returned to the controller, but when i echo it to see what it is i get: "Resource id #46" Isnt it supposed to return TRUE or FALSE...? Thanks simple_query() return...? - El Forum - 05-01-2008 [eluser]TheFuzzy0ne[/eluser] No. $this->db->simple_query() returns the database resource (results) for the query you just executed. You'd probably be better of counting if any rows are returned from the query. simple_query() return...? - El Forum - 05-01-2008 [eluser]rvent[/eluser] so: Code: $this->db->query("INSERT ......"); So the above returns TRUE if insert is successful and FALSE if it fails... right..? Thanks simple_query() return...? - El Forum - 05-01-2008 [eluser]James Gifford[/eluser] Yes that's right. Write-type queries like inserts and updates will return true/false while read-type queries will return the results. simple_query() return...? - El Forum - 05-01-2008 [eluser]rvent[/eluser] Well i have this new test function in my controller Code: $chkPart = $this->SmtJob->isPart(); //queries DB to check is part is unique and this on my model Code: $part = '100022810'; and i cant seem to get the result from the query. I get this on the page reload Code: -- Part -- TEST1 --] Line 52 is the echo line in the model... What am i missunderstanding...? shouldnt i be getting the value...? i am possitive that the value exist in the DB.. Thats where i got it from... Any ideas..? Thanks simple_query() return...? - El Forum - 05-01-2008 [eluser]rvent[/eluser] NEVER MIND I missed the line where it tells me that i need to use result() Thanks ![]() |