Welcome, Guest. Please login or register.
Did you miss your activation email?
Sep. 02, 2010, 07:48:28 PM
53844 Posts in 11998 Topics by 11375 Members
Latest Member: elizablackmore7
News:
 
The PRADO Community » Prado-related Projects » PetShop Project » setDataSource with an array of objects? « previous next »
Pages: [1] Print
Author Topic: setDataSource with an array of objects?  (Read 21523 times)
christocracy
Senior Member
***

Karma: 2
Offline Offline

Posts: 95


View Profile WWW
« on: Feb. 24, 2005, 09:39:13 PM »

Hello Mr. Wei & Mr. Jasrags.  I've implemented your PetShop DAO design in my current project.  very nice.

I'm starting to bubble the Service objects up to the interface now and I'm getting errors when trying to set the datasource of my TDataGrid.

Code:

$inv = new InventoryService();
//TDataGrid
$this->recordset->setDataSource($inv->getManufacturerList());


Fatal error: Cannot use object of type Manufacturer as array in /usr/local/lib/php/prado/framework/Web/UI/WebControls/TButtonColumn.php on line 188

I guess I'll kill the call to the populate(Array $row) function and return an array of rows instead?
Logged

wei
PRADO v3.x Developer
Diamond Member
*****

Karma: 65
Offline Offline

Posts: 2869



View Profile
« Reply #1 on: Feb. 24, 2005, 11:07:01 PM »

if you want to use the objects as in the datasource for datagrid, the objects need to implement ArrayAccess

e.g.

Code:
class Manufacturer implements ArrayAccess


or as in the PetShop example, just let the Prototype implement ArrayAccess.
CVS was updated, please allow 24 hours for the public CVS to catch up.


The new code allows something like the following
Code:

$item = new Item(); //e.g. class Item extends Prototype
echo $item->ItemID; //member variable read
echo $item['ItemID']; //same as above but using array index

echo $item->Category->Name; // dereferenced object
echo $item['Category']->Name; // as above
echo $item['Category']['Name'] //as above if Category is also a Prototype

foreach($item as $property => $value) //iterate throught all the properties
echo "$property => $value \n";


Wei.
Logged
mu_lover
Junior Member
**

Karma: 0
Offline Offline

Posts: 21



View Profile
« Reply #2 on: Jul. 14, 2008, 01:47:47 PM »

Hello... Can you upload the sample files?? Thank a lot!!
Logged
Pages: [1] Print 
« previous next »
Jump to: