DataObjects keys definition through keys() method is not clear for me...

From: Date: Mon, 01 Dec 2003 13:48:17 +0000
Subject: DataObjects keys definition through keys() method is not clear for me...
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-9234@lists.php.net to get a copy of this message
I'm new to DataObjects and I'm trying its features... I got a few problems using "get()" and "update()" methods... Both seems not to understand the data type provided to keys() method... The keys() expects as parameter an array: <synopsis> object $DB_DataObject->keys ([array $keys]) </synopsis> and an example shown in documentation says that too: <example> <?php (...) // now use it to define a on the fly database table... $d = new DB_DataObject; $d->tableName('person'); $d->table(array( 'id' => DB_DATAOBJECT_INT, 'name' => DB_DATAOBJECT_STRING, )); $d->keys(array('id')); (...) ?> Example 20-1. getting the connection </example> But passing an array makes get() and update() not to work.... The work around is setting keys() with a string and not as an array: $d->keys('id'); That works! Using array I get an error like "update: No Data specifed for query (...)" for update and it doesn't filter the query using get() method, fetching the first row of table... I noticed while using get() or update() methods, that DataObject class deals with the keys as an array, for example when asks: <code> if ($filter) { if (!in_array($k, $filter)) { continue; } </code> line 1700 - update method -> "* $Id: DataObject.php,v 1.154 2003/11/20 07:34:28 alan_k Exp $" But the table's field $k will never be found in the array $filter cause its content is another array of fields... $k = id $filter = array(0=>array('id')) instead of $filter = array('id'); I couldn't understand how it became an array inside another array since I passed it as an simple array.... Any suggestions about what's happening? Or how to deal with that? That's it.... Netto

« previous php.pear.general (#9234) next »