MODX Community

MIGX with xPDOSimpleObject not creating id field in new table

I am using MIGX to create a table using the schema below (the < has been omitted at the start of each line as difficult to copy and paste the code!).

Any reason for this as each of the other table fields are created?

<?xml version="1.0" encoding="UTF-8"?>
model package="players" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
object class="player" table="playerdetails" extends="xPDOSimpleObject">
field key="playername" dbtype="varchar" phptype="string" precision="100" null="false" default="" />
field key="gender" dbtype="varchar" phptype="string" precision="10" null="false" default="" />
field key="published" dbtype="int" phptype="integer" precision="1" attributes="unsigned" null="false" default="0" />
/object>
/model>

Have you tried using " instead of the and -characters?
It works on my system with this code:

<?xml version="1.0" encoding="UTF-8"?>
<model package="players" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
	<object class="player" table="playerdetails" extends="xPDOSimpleObject">
		<field key="playername" dbtype="varchar" phptype="string" precision="100" null="false" default="" />
		<field key="gender" dbtype="varchar" phptype="string" precision="10" null="false" default="" />
		<field key="published" dbtype="int" phptype="integer" precision="1" attributes="unsigned" null="false" default="0" />
	</object>
</model>

Thanks halftrainedharry
I copied your code and used it but the new table did not have an id field.
My keyboard only has the one " key so I don’t know what you are referring to.

I am using Modx 2.7.3 with PHP version 7.3.6 and Bootstrap template.

My system error log is:

[Mon Jul 27 07:03:07.187164 2020] [authz_core:error] [pid 728156:tid 22524578150144] [client 173.254.29.24:55344] AH01630: client denied by server configuration: /home2/beacona1/public_html/honours/core/docs/changelog.txt
[Mon Jul 27 07:03:00.092902 2020] [authz_core:error] [pid 717224:tid 22524636985088] [client 173.254.29.24:55270] AH01630: client denied by server configuration: /home2/beacona1/public_html/honours/core/docs/changelog.txt
[Mon Jul 27 03:51:34.318606 2020] [authz_core:error] [pid 377376:tid 22524618073856] [client 173.254.29.24:38212] AH01630: client denied by server configuration: /home2/beacona1/public_html/honours/core/docs/changelog.txt

  • Are there any relevant errors in the modx error log?
  • Is the line 'extends' => 'xPDOSimpleObject', in the file core/components/players/model/players/mysql/player.map.inc.php?
  • Have you change the schema, after you had already created the table in the database?
  • Did you delete the table in the database before clicking the "create Tables"-button for a second time?

Thanks halftrainedharry

The player.map.inc.php file is:

<?php
$xpdo_meta_map['player']= array (
  'package' => 'players',
  'version' => '1.1',
  'table' => 'playerdetails',
  'extends' => 'xPDOSimpleObject',
  'tableMeta' => 
  array (
    'engine' => 'MyISAM',
  ),
  'fields' => 
  array (
    'playername' => '',
    'gender' => '',
    'published' => 0,
  ),
  'fieldMeta' => 
  array (
    'playername' => 
    array (
      'dbtype' => 'varchar',
      'phptype' => 'string',
      'precision' => '100',
      'null' => false,
      'default' => '',
    ),
    'gender' => 
    array (
      'dbtype' => 'varchar',
      'phptype' => 'string',
      'precision' => '10',
      'null' => false,
      'default' => '',
    ),
    'published' => 
    array (
      'dbtype' => 'int',
      'phptype' => 'integer',
      'precision' => '1',
      'attributes' => 'unsigned',
      'null' => false,
      'default' => 0,
    ),
  ),
);

The modx error log is:

[2020-07-27 09:35:44] (ERROR in modProcessor::run @ /home2/beacona1/public_html/honours/core/model/modx/modprocessor.class.php : 177) Flat file processor support, used for action mgr/migxdb/getList with path /home2/beacona1/public_html/honours/core/components/migx/processors/mgr/migxdb/getlist.php, is deprecated since version 2.7.0. 
[2020-07-27 09:37:24] (ERROR in modProcessor::run @ /home2/beacona1/public_html/honours/core/model/modx/modprocessor.class.php : 177) Flat file processor support, used for action mgr/migxdb/getList with path /home2/beacona1/public_html/honours/core/components/migx/processors/mgr/migxdb/getlist.php, is deprecated since version 2.7.0. 
[2020-07-27 09:37:48] (ERROR in modProcessor::run @ /home2/beacona1/public_html/honours/core/model/modx/modprocessor.class.php : 177) Flat file processor support, used for action mgr/migxdb/getList with path /home2/beacona1/public_html/honours/core/components/migx/processors/mgr/migxdb/getlist.php, is deprecated since version 2.7.0. 
[2020-07-27 09:42:47] (ERROR in modProcessor::run @ /home2/beacona1/public_html/honours/core/model/modx/modprocessor.class.php : 177) Flat file processor support, used for action mgr/migxdb/getList with path /home2/beacona1/public_html/honours/core/components/migx/processors/mgr/migxdb/getlist.php, is deprecated since version 2.7.0. 

Each time I have tried it I have deleted the table from the database before creating the table and I am using the schema you posted earlier.

Thanks for your help so far.

No idea what the problem is. It all looks good to me!
More as a workaround than a solution you could try this schema, where xPDOSimpleObject isn’t used and the column id is defined directly in the schema.

<?xml version="1.0" encoding="UTF-8"?>
<model package="players" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">	
	<object class="player" table="playerdetails" extends="xPDOObject">
		<field key="id" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" index="pk" generated="native" />
		<field key="playername" dbtype="varchar" phptype="string" precision="100" null="false" default="" />
		<field key="gender" dbtype="varchar" phptype="string" precision="10" null="false" default="" />
		<field key="published" dbtype="int" phptype="integer" precision="1" attributes="unsigned" null="false" default="0" />
		
		<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
			<column key="id" collation="A" null="false" />
		</index>
	</object>
</model>