与PDO

2013-07-26 33 views
0

执行存储过程我有一个存储过程调用updateLosingSelections与PDO

当我在我的MySQL数据库运行

call updateLosingSelections 

直接产生预期的结果。

当我尝试使用pdo从一个php页面运行它时,什么也没有发生,但同样没有抛出或显示错误。我在这里错过了很明显的东西吗这是我的PHP页面的代码。

<?php 
session_start(); 
include_once('../connections/connection.php'); 
$sql_update_standings = 'call updateLosingSelections()'; 
$sth = $dbh->prepare($sql_update_standings); 
$sth->execute(); 
?> 

谢谢你们。 DS

编辑...最后,我把SQL存储在我的存储过程中,并将其作为SQL代码存放在pdo语句中。把我的头发撕掉对我来说并不好。

+0

你期望发生什么? –

+0

我期待在我的数据库更新中有一个表。就像我说的那样,如果我直接在mysql db中运行“call updateLosingSelections” – dstewart101

回答

0

我的第一个明显的问题是,当updateLosingSelections()没有参数时,为什么要将$ data数组传递给execute()?

本质:

//turn this 
$sth->execute($data); 

//into this 
$sth->execute(); 


//or if you want to do this 
$sth->execute($data); 

//then make sure to do this 
session_start(); 
include_once('../connections/connection.php'); 
$sql_update_standings = 'call updateLosingSelections(?,?)'; //two question marks as placement holders 
$sth = $dbh->prepare($sql_update_standings); 
$sth->execute($data('somedata','moredata')); //two pieces of data which will replace the two ? marks above 

我建议考虑看看DB2文档,似乎颇为相似。 http://pic.dhe.ibm.com/infocenter/db2luw/v9r7/index.jsp?topic=%2Fcom.ibm.swg.im.dbclient.php.doc%2Fdoc%2Ft0023502.html

+0

啊......我从之前的另一个pdo声明中剪切并粘贴。那不应该在那里。谢谢...但仍然失败:(没有错误信息,像以前一样,现在试着使用reconda的建议 – dstewart101

+0

这可能是一个愚蠢的问题,但是在connection.php文件中声明了$ ......如果是,那么它是否成功连接? – MonkeyZeus

+0

这里没有愚蠢的问题,猴子!是的,连接很好。使用在很多地方。这是唯一不起作用的地方:( – dstewart101