Creating Objects
What is an Object?
An "Object" in xPDO is simply an abstract, class-based representation of a row in a table in a database. In other words, a row in the table 'cars' would have an xPDO model definition of the 'cars' table, and then you would grab Collections of Objects of each car.
xPDO defines these Objects using the xPDOObject class.
Creating an Object
Creating objects in xPDO utilizes the "newObject" xPDO method.
Let's say we have an object defined in our model of class "Box". We want to create a new object of it:
$myBox = $xpdo->newObject('Box');
It's that simple. We can also create the Box object with some pre-filled field values:
$myBox = $xpdo->newObject('Box',array( 'width' => 5, 'height' => 12, 'color' => 'red', ));
This will give us an xPDOObject-based Box object that can be manipulated and saved. Note that this Object is not yet persistent until you save it using xPDOObject.save.
See Also
Suggest an edit to this page on GitHub (Requires GitHub account. Opens a new window/tab).