|
本帖最后由 ci_user 于 2011-8-9 09:29 编辑
大家好,我是纯粹新手
我使用以下语句
PHP复制代码 $sql = " SELECT @maxorder := CASE WHEN MAX(displayorder) IS NULL THEN 0 ELSE MAX(displayorder) END
FROM activitycategory
WHERE parentcategoryid = ?;
INSERT INTO activitycategory(categoryname, parentcategoryid, status, displayorder)
VALUES (?, ?, 1, @maxorder +1) ";
$this->db->query($sql, array($parentcategoryid, $categoryname, $parentcategoryid)); 复制代码
返回错误是:
A Database Error OccurredError Number: 1064
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 ' INSERT INTO activitycategory(categoryname, parentcategoryid, status, dis' at line 3
SELECT @maxorder := CASE WHEN MAX(displayorder) IS NULL THEN 0 ELSE MAX(displayorder) END FROM activitycategory WHERE parentcategoryid = 24, INSERT INTO activitycategory(categoryname, parentcategoryid, status, displayorder) VALUES ('test3', 24, 1, @maxorder +1)
Filename: D:\wamp\www\system\database\DB_driver.php
Line Number: 330
我把上面的sql单独放在mysql中执行可以成功,请求高手帮助,谢谢
|
|