Hi,
I’ve created a few objects that use inheritance:
Person -> User -> Advertiser
-> Member
-> Admin
I have to use ’include_once’ in the class files of child objects, or xPDO complains that it can’t find the parent class file. Is there something I’m missing? I notice that the 0.9.7 class files don’t have to do this.
I’m using a recent version of xPDO - just checked out yesterday.
Also, I’ve forgotten - will xPDO automatically generate tables for objects the first time an object is saved? I’m getting the following error:
[2007-05-30 14:27:51] (DEBUG @ /index.php) Returning table name: `member` for class: Member
[2007-05-30 14:27:51] (DEBUG @ /index.php) No primary key value found for pk definition:
[2007-05-30 14:27:51] (DEBUG @ /index.php) Executing SQL: INSERT INTO `member` (`dob`, `gender`) VALUES (:dob, :gender) with bindings: Array ( [:dob] => Array ( [value] => [type] => 1 ) [:gender] => Array ( [value] => NULL [type] => 0 ) )
Fatal error: Call to a member function execute() on a non-object in C:\wamp\www\xpdo\xpdo\om\xpdoobject.class.php on line 945
My tables don’t exist, but i’m getting the "No primary key value found" error I’ve had before (on a different project). I fixed it last time by inserting my own definition for the id fields into the schema since it wasn’t being inherited properly from the base class for some reason.
My basic schema is:
<?xml version="1.0" encoding="UTF-8"?>
<model package="test" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM">
<object class="Advertiser" table="advertiser" extends="User">
<field key="company" dbtype="varchar" precision="50" phptype="string" null="true" />
<field key="city" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
<field key="phone" dbtype="varchar" precision="30" phptype="string" null="true" default="" />
</object>
<object class="Member" table="member" extends="User">
<field key="dob" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="true" default="" />
<field key="gender" dbtype="enum" precision="'M','F'" phptype="string" null="true" />
</object>
<object class="Person" table="person" extends="xPDOObject">
<field key="firstname" dbtype="varchar" precision="200" phptype="string" null="false" default="" />
<field key="lastname" dbtype="varchar" precision="200" phptype="string" null="false" default="" />
<field key="email" dbtype="varchar" precision="60" phptype="string" null="false" default="" />
</object>
<object class="User" extends="Person">
</object>
</model>
If I do have to create the tables myself first, do I have to create a ’user’ table? And do I need any additional fields to the ones in my schema? How does xPDO keep track of which rows in the different tables make up any particular object of a sub-class?
Thanks in advance