Hi,
I’m currently adding custom tables to MODX 3 which seems to be a bit different than with MODX 2. according to Using Custom Database Tables - Tutorials | MODX Documentation
I’ve adjusted the folders/locations accordingly and I’ve changed the xml schema with namespaces etc. When building the Schema, the Modal folder is added to the src folder with all classes in it, so that seems to be ok. But it looks like the namespace is not adding the classname.
Below the cdbTeam.php file from the Model dir. In the docs it says the namespace should be something like ‘namespace CustomDatabase\Model\cdbTeam’
<?php
namespace CustomDatabase\Model;
use xPDO\xPDO;
/**
* Class cdbTeam
*
* @property string $naam
* @property string $teamtype
* @property float $lat
* @property float $lng
* @property integer $radius
* @property integer $aantal_bomen
* @property integer $landschap_id
* @property string $createdon
* @property integer $createdby
* @property string $editedon
* @property integer $editedby
*
* @package CustomDatabase\Model
*/
class cdbTeam extends \xPDO\Om\xPDOSimpleObject
{
}
When I try to create the tables I get an error that the classes don’t exist.
(class_exists(“Customdatabase\Model\cdbTeam”) always returns ‘false’.
Any ideas?
If needed, the xml begins like this:
<?xml version="1.0" encoding="utf-8"?>
<model package="CustomDatabase\Model" baseClass="xPDO\Om\xPDOObject" platform="mysql" defaultEngine="MyISAM" version="3.0">
<!-- TABEL cdbTeam -->
<object class="cdbTeam" table="cdb_team" extends="xPDO\Om\xPDOSimpleObject">
<field key="naam" dbtype="varchar" precision="100" phptype="string" null="true" default="" />
<field key="teamtype" dbtype="varchar" precision="100" phptype="string" null="true" default="vast" /><!--vast/flexibel-->
<field key="lat" dbtype="float" precision="16,14" phptype="float" null="true" default="" />
<field key="lng" dbtype="float" precision="16,14" phptype="float" null="true" default="" />
<field key="radius" dbtype="int" precision="1" phptype="integer" null="false" default="5" /><!--kms rond locatie-->
<field key="aantal_bomen" dbtype="int" precision="1" phptype="integer" null="false" default="5" />
<field key="landschap_id" dbtype="int" precision="1" phptype="integer" null="false" default="0" />
<field key="createdon" dbtype="datetime" phptype="datetime" null="true"/>
<field key="createdby" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
<field key="editedon" dbtype="datetime" phptype="datetime" null="true"/>
<field key="editedby" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
<aggregate alias="Landschap " class="CustomDatabase\Model\cdbLandschap" local="landschap_id" foreign="id" cardinality="one" owner="foreign"/>
<aggregate alias="CreatedBy " class="MODX\Revolution\modUser" local="createdby" foreign="id" cardinality="one" owner="foreign"/>
<aggregate alias="EditedBy " class="MODX\Revolution\modUser" local="editedby" foreign="id" cardinality="one" owner="foreign"/>
</object>