尝试将 "insert and update" 查询转换为 mysqli

Trying to convert into mysqli an "insert and update" query

我有这个 MySQL 句子,它在同一查询中使用插入和更新:

if(mysql_query('insert into forum_topics (parent, id, id2, title, message, authorid, timestamp, timestamp2) select "'.$dn1['parent'].'", "'.$id.'", max(id2)+1, "", "'.$message.'", "'.$_SESSION['SESS_MEMBER_ID'].'", "'.time().'", "'.time().'" from forum_topics where id="'.$id.'"') and mysqli_query('update forum_topics set timestamp2="'.time().'" where id="'.$id.'" and id2=1'))

我试图以这种方式将其转换为 mysqli

$qry = 'insert into forum_topics (parent, id, id2, title, message, authorid, timestamp, timestamp2) select "'.$dn1['parent'].'", "'.$id.'", max(id2)+1, "", "'.$message.'", "'.$_SESSION['SESS_MEMBER_ID'].'", "'.time().'", "'.time().'" from forum_topics where id="'.$id.'"';
$qry2 = 'update forum_topics set timestamp2="'.time().'" where id="'.$id.'" and id2=1';
$dn3 = $link -> query($qry AND $qry2);

if (!$dn3)...

不幸的是,它似乎不起作用,因为我被抛出了这个错误:

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1

有人可以帮忙吗?

如果要按照原来的逻辑,那么

$dn3 = ($link -> query($qry) AND $link->query($qry2));

由于 php 代码中的逻辑与运算符,2 个查询字符串在提交给 mysql 之前在布尔运算中进行了解释。

因此,值 1(真)被发送到 mysql,这显然导致了语法错误消息。