I am fetching the three values from TUsers using select query where I am getting the error as
Mysqli statement execute error : Result consisted of more than one row.
I have used DISTINCTROW for avoiding duplication and I am using Zend framework to call the procedure.
Here is the code:
Procedure:
CREATE DEFINER=`root`@`` PROCEDURE `spfetchloginid`(in securityans varchar(50),out email varchar(50),out loginidout varchar(50),out useridout varchar(50))
BEGIN
SELECT DISTINCTROW Email,login_id,user_id into email,loginidout,useridout FROM DB.TUsers where SecurityAns=securityans ;
END
Calling the Procedure in ZendFramework from Controller:
$db=Zend_Db_Table::getDefaultAdapter();
$spParams = array(1,'NewValue');
$stmt = $db->query("CALL spfetchloginid('$securityans',@email,@loginidout,@useridout)");
print_r($stmt->fetchAll());
$stmt->closeCursor();
$stmtresult10=$db->query("select @email");
$email_to=$stmtresult10->fetch();
$stmtresult10->closeCursor();
$Emails=$email_to["@email"];
echo $Emails;
$stmtresult11=$db->query("select @loginidout");
$loginid=$stmtresult11->fetch();
$stmtresult11->closeCursor();
$loginids=$loginid["@loginidout"];
echo $loginids;
$stmtresult12=$db->query("select @useridout");
$userid=$stmtresult12->fetch();
$stmtresult12->closeCursor();
$userids=$userid["@useridout"];
echo $userids;
Please tell me any good suggestions when using Zend and My Sql for calling the procedures.
From the fine manual:
So saying this:
just removes duplicates from the result set but if you have multiple rows with the same
SecurityAnsand they’re allsecurityans, then your query will return multiple rows. IfSecurityAnsis an answer to a standard question like “what is your favorite color” or “what was your mother’s maiden name” then you should be expecting a lot of duplicates soSecurityAnsis certainly not sufficient to guarantee uniqueness.You need to add more to the WHERE clause to guarantee unique results. Or, you could add LIMIT 1 but that’s just a bandage over the real problem.
You’re also probably running into a problem with your WHERE clause:
the should be true for every row in the table because I think the
securityanscolumn name will be used rather than thesecurityansparameter. Try using a different parameter name. For example, I see your duplicate problem with a procedure like this:but not with this version: