Uutiset:

Wondering if this will always be free?  See why free is better.

Main Menu
Advertisement:

Insert null value into db

Aloittaja vladefix, marraskuu 16, 2013, 05:48:01 AP

« edellinen - seuraava »

vladefix

Hy,
is there a way to update a column to a null value in a statement like the folowing :


$smcFunc['db_query']('', "
   UPDATE `{db_prefix}mytable`
      SET
         `name` = {string:name},
         `fk_dummy` = {int:id_dummy}
     WHERE
         `id` = {int:id}",
         array('name' => 'test', 'id_dummy' => '', 'id' => 1));

the column is a foreign key so i can't just insert 0 or -1

Thanks

emanuele

Probably something like:
$smcFunc['db_query']('', "
   UPDATE `{db_prefix}mytable`
      SET
         `name` = {string:name},
         `fk_dummy` = {raw:id_dummy}
     WHERE
         `id` = {int:id}",
         array('name' => 'test', 'id_dummy' => 'null', 'id' => 1));


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

vladefix

Lainaus käyttäjältä: emanuele - marraskuu 16, 2013, 06:09:52 AP
Probably something like:
$smcFunc['db_query']('', "
   UPDATE `{db_prefix}mytable`
      SET
         `name` = {string:name},
         `fk_dummy` = {raw:id_dummy}
     WHERE
         `id` = {int:id}",
         array('name' => 'test', 'id_dummy' => 'null', 'id' => 1));


that worked
thank you

Arantor

Btw, SMF doesn't make this easier because SMF doesn't use null itself in any column, and there is actually a performance saving at the database level if a table has no null columns.
Holder of controversial views, all of which my own.


Advertisement: