I had a working custom model but I was making changes to it and I broke it somehow. Creating a new object with $modx->newObject()
works normally and I can set and access its properties but when I try to ->save()
it I get the following error:
PHP warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: parameter was not defined
It also gives me Error HY093 executing statement:
and outputs the SQL statement in question. It sounds like I’m either missing some fields or have too many fields, but I can’t see which ones and I’m not sure why that would even happen, given all this is generated by the build scripts.
What could have gone wrong here? It was working until I tried to change it. I modified my schema, deleted the src/ directory, dropped the table, and ran the build scripts again. The same files as before were generated and the table was recreated with fields reflecting the updated schema–but now I can’t save anything.
TIA!
Can you post the schema you’re using?
Sure.
<?xml version="1.0" encoding="UTF-8"?>
<model package="FBECEvents\Model" baseClass="xPDO\Om\xPDOObject" platform="mysql" defaultEngine="InnoDB" version="3.0">
<object class="fbecEvent" table="fbec_events" extends="xPDO\Om\xPDOSimpleObject">
<!-- contact -->
<field key="applicant" dbtype="varchar" precision="255" phptype="string" null="false" />
<field key="event_name" dbtype="varchar" precision="255" phptype="string" null="false" />
<field key="contact_address" dbtype="varchar" precision="255" phptype="string" null="false" />
<field key="contact_person" dbtype="varchar" precision="255" phptype="string" null="false" />
<field key="phone_number" dbtype="varchar" precision="255" phptype="string" null="false" />
<field key="email_address" dbtype="varchar" precision="255" phptype="string" null="false" />
<!-- info -->
<field key="event_type" dbtype="varchar" precision="255" phptype="string" null="false" />
<field key="start_date" dbtype="date" phptype="date" null="false" />
<field key="end_date" dbtype="date" phptype="date" null="false" />
<field key="load_in_day" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="load_out_day" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="event_hours" dbtype="varchar" precision="255" phptype="string" null="false" />
<field key="attendee_count" dbtype="int" precision="10" phptype="integer" null="false" />
<field key="public" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="ticketed" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<!-- spaces -->
<field key="main-full" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="main-east" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="main-west" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="south-full" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="south-east" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="south-west" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="south-a" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="south-b" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="south-c" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="south-d" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="terrace" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="corridor" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<!-- details -->
<field key="previously_held" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="previously_held_where" dbtype="varchar" precision="255" phptype="string" null="false" />
<field key="vendors" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="vendor_count" dbtype="int" precision="10" phptype="integer" null="false" />
<field key="exempt" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="exempt_docs" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="catering" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="kiosks" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="alcohol" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="alcohol_days" dbtype="varchar" precision="255" phptype="string" null="false" />
<field key="projector" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="wifi" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="fbec_social_media" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="fbec_website" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="ag_center_marquee" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<!-- states -->
<field key="review_status" dbtype="enum" precision="'unreviewed', 'waiting','approved','rejected'" phptype="string" null="false" default="unreviewed" />
<field key="contract_received" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="deposit_received" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="rent_paid" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="security_finalized" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="food_finalized" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="alcohol_finalized" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="av_finalized" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<field key="coi_received" dbtype="tinyint" precision="1" phptype="boolean" null="false" default="0" />
<index alias="start_date" name="start_date" primary="false" unique="false" type="BTREE">
<column key="start_date" length="" collation="A" null="false" />
</index>
<index alias="review_status" name="review_status" primary="false" unique="false" type="BTREE">
<column key="review_status" length="" collation="A" null="false" />
</index>
</object>
</model>
dev_willis:
<field key="main-full"
My guess is, that the code doesn’t like dashes (-
) in the field keys.
Try using underscores (e.g. key="main_full" ...
) instead.
1 Like
system
Closed
May 5, 2024, 1:48am
6
This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.