|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-03-20 19:26 UTC] key88sf at gmail dot com
Description:
------------
I have a simple stored procedure in MySQL 5.x. The proc first does a SELECT INTO query, followed by a regular SELECT to return it's result set.
The SELECT INTO generates a warning 1329 because no rows were fetched. However, the final SELECT works properly and returns 1 row.
However, the result returned from mysqli_query() is NULL !
Reproduce code:
---------------
Stored proc is this:
DECLARE v_affiliate_id INTEGER DEFAULT NULL;
-- This SELECT INTO returns 0 rows:
select
affiliate_id INTO v_affiliate_id
from
affiliates
where
user_name = v_user_name
and password_hash = v_password_hash;
if ( v_affiliate_id IS NULL ) THEN
SET v_affiliate_id := -1;
end if;
-- This is the result set row:
select v_affiliate_id;
Expected result:
----------------
When I run this from the MySQL command line, I get 1 row, 1 warning (1329).
When I run from PHP, I *expect* to see a result set with 1 row.
Actual result:
--------------
When I run from PHP, the result set from mysqli_query() is NULL.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 06:00:02 2025 UTC |
Database table to create (MySQL): CREATE TABLE affiliates ( affiliate_id int(11) NOT NULL auto_increment, user_name varchar(32) NOT NULL, password_hash char(32) NOT NULL, PRIMARY KEY (affiliate_id), UNIQUE KEY Index_User_Name (user_name) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; INSERT INTO affiliates (user_name, password_hash) VALUES( 'test', '9b93b6ff07bfb6463bd0b5a6e65c4125' ); PHP Script to Demonstrate Bug: <?php $dbConnection = mysqli_connect("localhost", "root", "password"); $userName = "test"; $passwordHash = md5("some junk"); $sql = sprintf("CALL LoginAffiliate('%s', '%s')", $userName, $passwordHash); $recordSet = mysqli_query( $dbConnection, $sql ); if ( !$recordSet ) { echo "ERROR:" . strval(mysqli_errno($dbConnection)); } else { echo "SUCCESS"; } die(); ?>