为什么这个MySQL语句有效,但另一个不是?

时间:2015-08-21 15:58:14

标签: php mysql sql database wordpress

代码块#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的值为01。 MySQL中的hide列的类型为bool。当query$hide时,我的1都在工作,但当$hide0时,第一个代码块为'add' ,不工作。为什么???????

0 个答案:

没有答案