If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > PDO Output Parameter Problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-12-12, 01:11
bharanidharanit bharanidharanit is offline
Registered User
 
Join Date: Nov 2008
Posts: 115
PDO Output Parameter Problem

Hi,
I am using this SP, am getting both the result when using mysql workbench.
Code:
CREATE PROCEDURE SP(IN _start INT,IN _end INT,INOUT _count INT)
BEGIN

   SET _count = (SELECT COUNT(*) FROM tbl);

   SET @qry = CONCAT('select * from tbl limit ', _start, ',', _end);

   PREPARE stmt FROM @qry;
   EXECUTE stmt;
   DEALLOCATE PREPARE stmt;

END
But when using with PDO am returning this error
Code:
$c=0; 
$stmt = $this->_dbc->getConnection()->prepare("CALL SP(0,10,:count)"); 
    $stmt->bindParam(":count",$c,PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT,0); 
    $stmt->execute(); 
    return $c; 
PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1414 OUT or INOUT argument 3 for routine db22.SP is not a variable or NEW pseudo-variable in BEFORE trigger
But on changing
Code:
[php]$this->_dbc->getConnection()->prepare("CALL SP(0,10,:count)");
to
Code:
$this->_dbc->getConnection()->prepare("CALL SP(0,10,@count)");
am not returning any error, but always getting the count as 0.

1.Whats the difference between :count and @count ?
2.How to get exact count via pdo ?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On