I am using apache, php, mysql and code igniter and I have a database set up. In the database I have two columns, both of which should be unique in the combo: latitude and longitude
So I have set up the database using this call:
replace the pano_raw table Add unique index (latitude, LNG) Now when I add value to two columns (latitude and LNG), if the value is the same, then should the database be written correctly? Function addNewSet ($ data) {$ this- & gt; Db- & gt; Insert ('set', $ data); } Based on the success of reading or writing, should this function return true or false?
So how do I change it now so that when it is returned or returned the line_ID of the record recorded? If writing works, then I need a line_id, if I do not need a phalsee then I can change the code called this function.
Will this work? I do not think so? Function addNewSet ($ data) {$ this- & gt; Db- & gt; Insert ('set', $ data); Return $ the-> gt; & Gt; Insert_id (); } "
By default it does not get a false refund, it has a false before returning Database error will occur.
If you really want this, you set it wrong by going to application / config / database.php $ db ['default'] ['Db_debug '] = FALSE; Then you should be able to do this (assuming that the id field in your table is set to auto-engagement)
function AddNewSet ( $ Data) {if ($- >--> db- & gt; insert ('set', $ data)) {return $ this-> Db- & gt; Insert_id (); } And {return false; }}
Comments
Post a Comment