簡體   English   中英

用pdo執行存儲過程

[英]execute stored procedure with pdo

我有一個存儲過程調用updateLosingSelections

當我跑步

 call updateLosingSelections 

直接在我的mysql數據庫上會出現預期的結果。

當我嘗試從帶有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放置在pdo語句中,並將其作為sql代碼保留。 扯掉我的頭發對我不利。

我的第一個明顯問題是,為什么當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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM