Friday, 15 March 2013

php - CodeIgniter insert two rows instead one -


I have a problem with code igniter for some reason, insert two rows instead of database

down The code from model is:

  / ** * add new fuel * / public function addNewFuel ($ id = NULL, $ data) {if ($ ID) { Var_dump ('test'); $ Data = array ('value' = & gt; '333', 'fuel' => 'dieselka', 'petrol_id' => 66); Echo '& lt; Pre & gt; '; Print_r ($ data); Echo & lt; / Pre & gt; '; $ This- & gt; Db- & gt; Insert ('value', $ data); Revert $ the-> gt; & Gt; Last_query (); $ This- & gt; Db- & gt; Insert ('prices_archive', $ data); Return; }}  

And here is the output:

  string (4) "test" array ([value] => 333 [fuel] = & Gt; Dizelka [petrol_id] => 66)  

Edit:

This is the code from Controller which calls the model's function Function addnewfuel () (if ($ this-> Session-> User Data ('log in_in')) {$ this- & gt; Load- & Gt; Assistant ('form'); $ Id = $ this-> uri- & gt; Segment (3); $ fuel = $ this-> Input-> Post ('fuel'); $ Value = $ it- & gt; Input-> Post ('value'); $ AddNewFuel = array ('fuel' = & g $$ [$ fuel, 'value' = & gt; $ value]; $ data ['addNewFuel'] = $ this-> admin_model-> ] = $ This-> AdministratorModel-> GetFuels (); $ data ['getPetrolNameByID'] = $ this-> AdministratorModel- & gt; getPetrolNameByID (); $ data ['getPetrolInformation'] = $ this - & gt; Administratorem_model- & gt; GetPetrolInformation (); $ This- & gt; Load-> View ('Admin / Editing', $ data); } Else {// If there is no session, redirect to redirect the login page ('Login', 'Refresh'); }}

In table 'Prices' for some reasons I am getting two rows with the same data, and in fact I do not know why this happens.

Thanks

You are going to insert both data from the model along with the controller Are there.

Eliminate it from the model, hopefully the sick will solve the problem. Thanks

  $ data = array ('price' => '333', 'fuel' = & gt; 'dizelka', 'petrol_id' => '66 ');  

No comments:

Post a Comment