Hello ,
i have a table com_discussioni_dest with a field cod_gruppo INT(11)NULL DEFAULT NULL;
In an event onAfterInsert of a form application i make some insert in this table but when i insert a NULL value in the database it becomes 0 value (i have a variable $v_cod_gruppo tha i use to make the insert). When there is a real value for cod_gruppo all works fine. If i make the insert with an explicit NULL value without a variable it works
What could be the problem?
Regards
Gianpaolo
This is my code
$query=“select cod_utente,cod_gruppo”." from com_categorie_utgr"." where id_cat= ‘{id_cat}’";
sc_lookup(rs, $query);
$i=0;
while (isset({rs[$i][0]}))
{
if (isset({rs[$i][0]})) // Row found
{ // SQL statement parameters
$v_cod_utente={rs[$i][0]};
$v_cod_gruppo={rs[$i][1]};
if (is_null($v_cod_gruppo)) {$tipo_dest='U';} else {$tipo_dest='G';}
$insert_table = ‘com_discussioni_dest’; // Table name
$insert_fields = array(
‘id_dis’ => “’{id}’”,
‘tipo’ => “’$tipo_dest’”,
‘cod_utente’ => “’$v_cod_utente’”,
‘cod_gruppo’ =>"’$v_cod_gruppo’",
‘utente_mod’ => “’{utente_mod}’”,
‘data_mod’ => “’{data_mod}’”
);
// Insert record
$insert_sql = ‘INSERT INTO ’ . $insert_table
. ’ (’ . implode(’, ‘, array_keys($insert_fields)) . ‘)’
. ’ VALUES (’ . implode(’, ', array_values($insert_fields)) . ‘)’;
sc_exec_sql($insert_sql);
}
$i=$i+1; }