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>

I am now back on the project.

I have two custom tables, one for players and another for the honours they have achieved in a club. I am trying to use a list box from the players table with a list of players to select the one I want to use to create a record in the honours table.

I am using formit and migxloopcollection as a select tool. However, when I try to create an honours record the name does not get selected, a 0 is input into the playername field.

The migxloopcollection select tlpoption was suggested by halftrainedharry some months ago.

The resource code is.
[[!FormIt?
&hooks=formit2db,redirect
&preHooks=db2formit
&prefix=agc_
&packagename=honours
&classname=honposition
&tablename=positionagc
&redirectTo=5
&store=1
&validate=nospam:blank, playername:required, position:required, yearwhen:required
]]

Add Position Form

[[!+fi.successMessage]] [[!+fi.validation_error_message:notempty=`

[[!+fi.validation_error_message]]

`]] Select position... Mens Captain Ladies Captain President Vice President
Select member ... [[!migxLoopCollection? &prefix=`agc_` &usecustomprefix=`agc_` &packageName=`honours` &classname=`player` &selectfields=`fullname,gender` &tpl=`tplOption` &sortConfig=`[{"sortby":"surname"}]` &where=`{"gender":"1"}` &selected=`[[!+fi.playername]]` ]]
Select member ... [[!migxLoopCollection? &prefix=`agc_` &usecustomprefix=`agc_` &packageName=`honours` &classname=`player` &selectfields=`fullname,gender` &tpl=`tplOption` &where=`{"gender":"2"}` &selected=`[[!+fi.playername]]` ]]
Select member ... [[!migxLoopCollection? &prefix=`agc_` &usecustomprefix=`agc_` &packageName=`honours` &classname=`player` &selectfields=`fullname,gender` &tpl=`tplOption` &selected=`[[!+fi.playername]]` ]]
Year Captain: [[!+fi.error.yearwhen]]
<div class="form-buttons">
    <input type="submit" value="Enter captain details" />
</div>

The tplOption is.

    <option value="[[+fullname]]" [[+fullname:eq=`[[+property.selected]]`:then=` selected="[[+fullname]]"`]]>[[+fullname]]</option>

The schema is:
<?xml version="1.0" encoding="UTF-8"?> <model package="honours" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1"> <object class="player" table="playerdetails" extends="xPDOSimpleObject"> <field key="timeset" dbtype="varchar" phptype="string" precision="25" null="false" default="" /> <field key="title" dbtype="varchar" phptype="string" precision="10" null="false" default="" /> <field key="initial1" dbtype="varchar" phptype="string" precision="10" null="false" default="" /> <field key="initial2" dbtype="varchar" phptype="string" precision="10" null="false" default="" /> <field key="initial3" dbtype="varchar" phptype="string" precision="10" null="false" default="" /> <field key="surname" dbtype="varchar" phptype="string" precision="100" null="false" default="" /> <field key="fullname" dbtype="varchar" phptype="string" precision="50" null="false" default="" /> <field key="gender" dbtype="int" phptype="string" precision="1" null="false" default="" /> <composite alias="captain" class="captain" local="fullname" foreign="playername" cardinality="many" owner="local"/> </object> <object class="honposition" table="positionagc" extends="xPDOSimpleObject"> <field key="playername" dbtype="varchar" phptype="string" precision="100" null="false" default="" /> <field key="position" dbtype="int" phptype="string" precision="1" null="false" default="" /> <field key="yearwhen" dbtype="int" phptype="integer" precision="10" null="false" default="0" /> <aggregate alias="player" class="player" local="playername" foreign="fullname" cardinality="one" owner="foreign" /> </object> <object class="competition" table="competitionagc" extends="xPDOSimpleObject"> <field key="compname" dbtype="varchar" phptype="string" precision="100" null="false" default="" /> <field key="comptype" dbtype="int" phptype="string" precision="1" null="false" default="" /> <field key="compdesc" dbtype="text" phptype="string" precision="500" null="false" default="0" /> </object> </model>

Any help would be useful.

It would be helpful, if you could put a line with 3 back-ticks at the start and the end of every code block (especially the one with the form), so everything is formatted correctly.

```//line with 3 back-ticks at the beginning
//your code here
```//line with 3 back-ticks at the end

could you solve your initial issue? Seems this is a new question now.
If so, describe how you solved it and start a new thread, please.

Thanks Bruno.
I reinstalled migx and now it creates tables correctly with an id field.
Do I need to copy my previous post into a new post now?