oracle数据库数据插入时出错,但是更新查询正常

浏览:2637 发布日期:2015/10/19 分类:求助交流
大家好,我这里遇到一个问题:

我使用ThinkPHP3.2.3访问oracle数据库,数据库名是wish,包含三个字段:wish_id, username, content。我分别进行了数据库的查询,更新和插入测试,结果显示:查询和更新都没有问题,但是做插入测试报错,下面是详细代码:

1. 查询
$result = M('wish')->select();
var_dump($result);
返回了数据库所有字段信息,正常

2. 更新
$data = array(
'wish_id' => '123456',
'username' => 'chendqing',
'content' => 'OK',
);

$result = M('wish')->data($data)->save();
var_dump($result);
返回更新记录数目,正常

3. 插入
$data = array(
'wish_id' => '1234567',
'username' => 'chendqing',
'content' => 'OK',
);

$result = M('wish')->data($data)->add();

结果报错,报错信息如下:
:(
SQLSTATE[HY000]: General error: 1008 OCIStmtExecute: ORA-01008: not all variables bound (ext\pdo_oci\oci_statement.c:148)
错误位置
FILE: D:\apacheroot\wish\ThinkPHP\Library\Think\Db\Driver\Oracle.class.php  LINE: 80
TRACE
#0 D:\apacheroot\wish\ThinkPHP\Library\Think\Db\Driver\Oracle.class.php(80): PDOStatement->execute()
#1 D:\apacheroot\wish\ThinkPHP\Library\Think\Db\Driver.class.php(830): Think\Db\Driver\Oracle->execute('INSERT INTO hd_...', false)
#2 D:\apacheroot\wish\ThinkPHP\Library\Think\Model.class.php(320): Think\Db\Driver->insert(Array, Array, false)
#3 D:\apacheroot\wish\Test\Home\Controller\IndexController.class.php(28): Think\Model->add()
#4 [internal function]: Home\Controller\IndexController->index()
#5 D:\apacheroot\wish\ThinkPHP\Library\Think\App.class.php(173): ReflectionMethod->invoke(object(Home\Controller\IndexController))
#6 D:\apacheroot\wish\ThinkPHP\Library\Think\App.class.php(110): Think\App::invokeAction(object(Home\Controller\IndexController), 'index')
#7 D:\apacheroot\wish\ThinkPHP\Library\Think\App.class.php(204): Think\App::exec()
#8 D:\apacheroot\wish\ThinkPHP\Library\Think\Think.class.php(120): Think\App::run()
#9 D:\apacheroot\wish\ThinkPHP\ThinkPHP.php(97): Think\Think::start()
#10 D:\apacheroot\wish\test.php(13): include('D:\\apacheroot\\w...')
#11 {main}

一直调试没有找到错在哪里,哪位又遇到类似问题吗?谢谢
最佳答案
评论( 相关
后面还有条评论,点击查看>>