![]() |
add 1 to highest number in table - 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: add 1 to highest number in table (/showthread.php?tid=26034) |
add 1 to highest number in table - El Forum - 01-04-2010 [eluser]rijobo[/eluser] Hello, I'm trying to add 1 to a number in my table. I use this function: Code: function getFactuurnr(){ When I do this, its keeps coming up with 2 and i get this warning: Severity: Notice Message: Object of class CI_DB_mysql_result could not be converted to int Filename: models/mfactuur.php Line Number: 12 Line 12 is Code: $nummernieuw = $nummeroud + 1; add 1 to highest number in table - El Forum - 01-04-2010 [eluser]Ben Edmunds[/eluser] Try this: Code: function getFactuurnr(){ add 1 to highest number in table - El Forum - 01-04-2010 [eluser]rijobo[/eluser] That's it, thank you! Could you explain to me why this is the solution? add 1 to highest number in table - El Forum - 01-04-2010 [eluser]Ben Edmunds[/eluser] No problem. Sure I can explain. $nummeroud is just the query and you have to call row(), row_array(), result(), result_array(), etc on it for it to return the object(s) or array(s) to work with. row() is used since you are only selecting one row from the DB and it returns the row as an object. If you were to do row_array it would return the row as an array so you would use $result['factuurnummer'] instead of $result->factuurnummer. Make sense? add 1 to highest number in table - El Forum - 01-04-2010 [eluser]rijobo[/eluser] thanks again, makes sense now! |