Results 1 to 1 of 1

Thread: PDO Output Parameter Problem

  1. #1

    Thread Starter
    Fanatic Member bharanidharanit's Avatar
    Join Date
    Oct 2008
    Location
    India
    Posts
    673

    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
    PHP 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
    PHP Code:
    $this->_dbc->getConnection()->prepare("CALL SP(0,10,**:count**)"); 
    to
    PHP 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 ?
    Last edited by penagate; Feb 12th, 2012 at 02:03 AM. Reason: Fixed code tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width