【发布时间】:2018-04-07 07:00:02
【问题描述】:
我还没有找到使用json_set 更新mysql 上的表的好语法。
你能给我一些帮助吗?我想更新并了解此查询的良好语法。
public function mkjson()
{
$friends = '"pachou", "eric", "francis"';
$tagfriendsjson = json_encode($friends);
try
{
include('connect.ini');
}
catch (Exception $e)
{
die('Erreur : '.$e->getMessage());
}
$ver = 'SELECT * FROM tagusers WHERE tag_users_id="'.$_SESSION['tagusersid'].'"';
$ask = $bdd->query($ver);
$ans = $ask->fetch();
if (empty($ans['tag_friends']))
{
$req = $bdd->prepare('UPDATE tagusers SET = {"1": "pachou", "2": "eric", "3": "francis", "4": "Henry"} WHERE tag_users_id="'.$_SESSION['tagusersid'].'" ');
$req->execute();
}
else
{
}
return true;
}
:未捕获的 PDOException:SQLSTATE[42000]:语法错误或访问冲突:1064 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在 /var/www/tagmeyou.com/php/ 的第 1 行的 '= {"4": "Henry"} WHERE tag_users_id="2"' 附近使用正确的语法class.Friendlist.php:34 堆栈跟踪:#0 /var/www/tagmeyou.com/php/class.Friendlist.php(34): PDOStatement->execute() #1 /var/www/tagmeyou.com/fr /vues/body/inputtag.php(23): 好友列表->mkjson() #2 /var/www/tagmeyou.com/fr/vues/body/bodytagscreen.php(10): include('/var/www/ tagmey...') #3 /var/www/tagmeyou.com/fr/vues/tagmeyou.php(34): include('/var/www/tagmey...') #4 {main} 抛出
【问题讨论】:
-
我真的不建议使用json作为字段值,太乱了:S