gpt4 book ai didi

PHP ADOdb Active Record::Replace() 错误(或功能?)

转载 作者:行者123 更新时间:2023-11-30 23:32:36 25 4
gpt4 key购买 nike

这是我的代码:

$user->user_id = 3;
$user->email='';
$user->password=md5('123456');
$user->Replace();

然后它生成一条sql:

UPDATE pre_user SET email=,password='e10adc3949ba59abbe56e057f20f883e' WHERE user_id=3

正如您所看到的,没有空字符串引号。然后我按照代码在 adodb-active-record.inc.php:631 运行 doquote() 并找到下面的代码:

    case 'C'://I think this means 'Char' and email field should be this.
case 'X':
if (is_null($val)) return 'null';

if (strlen($val)>0 &&
(strncmp($val,"'",1) != 0 || substr($val,strlen($val)-1,1) != "'")) {
return $db->qstr($val);
break;
}

它告诉如果 strlen($val)>0...

为什么不给空字符串加引号?

最佳答案

$user->email='' 不为空且长度为 0,doquote() 不处理这种特殊情况。

你可以试试:

$user->email = NULL;

但是您的数据库必须允许该字段的 NULL 值。

关于PHP ADOdb Active Record::Replace() 错误(或功能?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9808830/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com