代码块#1:
case 'add':
{
global $wpdb;
$message .= $wpdb->query("INSERT INTO projs (compname,projname,imageurl,sumsmall,sumfull,results,caseid,hide) VALUES (" . implode(",", array("'$compname'", "'$projname'", "'$imageurl'", "'$sumsmall'", "'$sumfull'", "'$results'", "$caseid", "$hide")) . ")")
? 'Successfully added project ' . $projname . ' to the database.'
: 'Error occurred when trying to add project to database: ' . $wpdb->last_error;
break;
}
代码块#2:
case 'update':
{
global $wpdb;
$message .= $wpdb->query("UPDATE projs SET compname='$compname',projname='$projname',imageurl='$imageurl',sumsmall='$sumsmall',sumfull='$sumfull',results='$results',caseid=$caseid,hide=$hide WHERE id=$id") !== false
? 'Successfully updated project.'
: 'Error occurred when trying to update project in database: ' . $wpdb->last_error;
break;
}
$hide
的值为0
或1
。 MySQL中的hide
列的类型为bool
。当query
为$hide
时,我的1
都在工作,但当$hide
为0
时,第一个代码块为'add'
,不工作。为什么???????