Welcome Guest, Not a member yet? Register   Sign In
db SELECT in concrete place
#5

[eluser]Josssi[/eluser]
Thanks for your reaction Wink, but i found a better solving I thing Wink...In db I create new column serial_number. If I want to add new item in my application, in form select i just choose item, before I want to place my new item, and in controller I will call model function, which will increment all serial_number = or > than serial_number of choosen item.
There is script of model method:
Code:
function addItemBefore($item_data)
{
  $value = 1;
  
  $this->db->where('serial_number >=', $item_data['serial_number'])
     ->set('serial_number', 'serial_number+'.$value, FALSE)
     ->update('products');
  
  $this->db->insert('products',$item_data);

}

note: serial_number cant be in db selected as PRMARY_KEY.


Messages In This Thread
db SELECT in concrete place - by El Forum - 03-24-2012, 06:25 PM
db SELECT in concrete place - by El Forum - 03-24-2012, 07:15 PM
db SELECT in concrete place - by El Forum - 03-24-2012, 08:24 PM
db SELECT in concrete place - by El Forum - 03-25-2012, 09:41 PM
db SELECT in concrete place - by El Forum - 03-25-2012, 09:58 PM



Theme © iAndrew 2016 - Forum software by © MyBB