#46614 [Opn->Fbk]: Extended MySQLi class gives incorrect empty() result

From: Date: Wed, 19 Nov 2008 23:12:58 +0000
Subject: #46614 [Opn->Fbk]: Extended MySQLi class gives incorrect empty() result
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-131127@lists.php.net to get a copy of this message
 ID:               46614
 Updated by:       jani@php.net
 Reported By:      sander dot vink at procurios dot nl
-Status:           Open
+Status:           Feedback
 Bug Type:         MySQLi related
 Operating System: Mac OS X 10.5.5
 PHP Version:      5.3CVS-2008-11-19 (snap)
 New Comment:

You set $this->fooData[]to contain 'Bar' -> it's not empty -> returns 
true..what's the bug..?


Previous Comments:
------------------------------------------------------------------------

[2008-11-19 13:25:11] sander dot vink at procurios dot nl

Description:
------------
When an empty() call is done within a class that extends the MySQLi
class, an incorrect result is provided.

Reproduce code:
---------------
class Foo extends MySQLi
{
	protected $fooData = array();
	
	public function isEmpty()
	{
		$this->fooData[] = 'Bar';
		return empty($this->fooData);
	}
}

$Foo = new Foo('localhost', 'root', '', 'test');
$isEmpty = $Foo->isEmpty();

var_dump($isEmpty);

Expected result:
----------------
bool(false)

Actual result:
--------------
bool(true)


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=46614&edit=1



Thread (5 messages)

« previous php.bugs (#131127) next »