MYSQL - empty string == 0 problem (updates row with primary key 0 instead of insert) -
actually worked , have no idea i've changed run problem now. tried everything.
the case:
have following query. variable $db-id empty string if content want save new. field module_id primary key. happens query updates row module_id => 0.
the problem
passing empty variable primary key updates row 0 instead of inserting new one.
$this->db->query("insert modules_text ( module_id, module_content, module_page_idx, module_post_id ) values ( '{$db_id}', '{$content['text']}', '{$content['idx']}', '{$post_id}' ) on duplicate key update module_content = '{$content['text']}', module_page_idx = '{$content['idx']}' ");
does have idea how can tell mysql create new row??? appreciated!!!! thank much!!!
saludos sacha!
you may need set primary key field auto increment. example below.
create table tablename ( id mediumint not null auto_increment, name char(30) not null, primary key (id))
Comments
Post a Comment