hotti: Problem mit NULL

Beitrag lesen

hi,

nein, der Code von L(in)uchs ist völlig in Ordnung (außer nicht besonders lesbar) und das vom OP beschriebene Verhalten läßt sich nicht nachvollziehen.

Stimmt: Nicht nachvollziehbar. Hab jetzt nochmal mysqli/mysql verglichen, Spalte text ist in MySQL NULL:

mysql> select * from test where id=677;
+-----+------+---------------------+
| id  | text | datum               |
+-----+------+---------------------+
| 677 | NULL | 2012-07-23 19:07:32 |
+-----+------+---------------------+
1 row in set (0.00 sec)

mysql> select version();
+------------------+
| version()        |
+------------------+
| 5.1.40-community |
+------------------+
1 row in set (0.02 sec)

  
include 'mysqli.php';  
  
class xperlbase extends Manager_MyBase{  
	function browse(){  
		$res = $this->DBH->query("SELECT * FROM test WHERE id = 677");  
		$r = mysqli_fetch_object($res);  
		if(!isset($r->text)) print "Not Set\n";  
		if(is_null($r->text)) print "Is NULL\n";  
	}  
}  
  
  
$mb = new xperlbase;  
$mb->browse();  
  
$conn = mysql_connect('localhost') or die(123);  
mysql_select_db('myweb') or die(234);;  
$res = mysql_query("SELECT * FROM test WHERE id = 677", $conn);  
$r = mysql_fetch_object($res);  
  
if(!isset($r->text)) print "Not Set\n";  
if(is_null($r->text)) print "Is NULL\n";  
  
print_r($r);  

Not Set
Is NULL
Not Set
Is NULL
stdClass Object
(
    [id] => 677
    [text] =>
    [datum] => 2012-07-23 19:07:32
)

Version PHP
PHP 5.3.0 (cli) (built: Jun 29 2009 21:25:23)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies

Hotti