mysql_fetch_object() with MYSQL_NUM or MYSQL_BOTH

From: Date: Fri, 24 Aug 2001 12:14:33 +0000
Subject: mysql_fetch_object() with MYSQL_NUM or MYSQL_BOTH
Groups: php.db 
Request: Send a blank email to php-db+get-11781@lists.php.net to get a copy of this message
hello ! mysql_fetch_object() is like mysql_fetch_array() but it returns an object and not an array. so you can access field through this syntax : $obj->fieldname (i.e $obj->amount) you can provide a second parameter to this function : MYSQL_ASSOC, MYSQL_NUM or MYSQL_BOTH. if you use MYSQL_NUM or MYSQL_BOTH, you should be able to access fields through the column number... but how since in an PHP object a variable could not begin by a numerical character (i.e $obj->0, $obj->1... is forbidden) ? if you use get_object_vars($obj) and print the object's properties, you could see this for example (MYSQL_BOTH used) : 0 = 'titi' columnName1 = 'titi' 1 = 2 columnName2 = 2 so here $obj->columnName1 returns 'titi' and $obj->columnName2 returns 2 but if i want to use numerical entries how to keep the object access behavior like $obj->... ? is it possible ? if not we should use a loop with get_object_vars($obj) ? nothing more simple and beautiful ? thanks for your feeebacks. regards, rashkatsa

« previous php.db (#11781) next »