Below is my stored procedure:
DELIMITER $$ -- -- Procedures -- DROP PROCEDURE IF EXISTS `checkLogin`$$ CREATE DEFINER=`root`@`localhost` PROCEDURE `checkLogin`(IN `uname` VARCHAR(255), IN `pwd` VARCHAR(255)) BEGIN SELECT a.id, a.role_id, b.name FROM userTable as a LEFT JOIN roleTable as b on b.id = a.role_id WHERE a.username = uname AND password = pwd; END$$ DELIMITER ; Below is my execution code:
$stmt = $this->dbCon->prepare("CALL checkLogin(?, ?)"); $stmt->bindParam(1, $email, PDO::PARAM_STR, 4000); $stmt->bindParam(2, $password, PDO::PARAM_STR, 4000); // call the stored procedure $stmt->execute(); //var_dump($res); $op = ( $stmt ) ? $stmt->fetchAll(PDO::FETCH_ASSOC) : ''; echo '<pre>'; print_r($op); die; in the above $this->dbCon is my PDO object.
When I execute this code I am getting only empty result. But when I run the procedure through phpmyadmin it is working fine.
Even it is working fine if I execute through command line:

I tried below method also (Received from Answer), But still its unsuccessful
$stmt = $db->prepare("Call checkLogin(?,?);"); $stmt->execute(array($email,$password)); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); if (count($rows) == 0) echo 'Failed Login!'."\n"; else echo 'Logged In...'."\n".print_r($rows,true);
$$is stopping the procedure on theDROP PROCEDUREline. MySQL Stored Procedures In general you're using the delimiter incorrectly as shown.