G
G
g0r0detskiy2013-12-05 14:51:12
MODX
g0r0detskiy, 2013-12-05 14:51:12

Can't save(), remove() on an object?

Actually, the problem is that this code does not change the value in the table.

$obj = $modx->getObject('LatestSite', array('user_id' => $customer));
$obj->set('site_id', $_POST['siteid']);
$obj->save();

Here is the xml:
<?xml version="1.0" encoding="UTF-8"?>
<model package="testpackage" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
  <object class="LatestSite" table="latest_site" extends="xPDOObject">
    <field key="user_id" dbtype="int" precision="10" phptype="integer" null="false" />
    <field key="site_id" dbtype="int" precision="10" phptype="integer" null="false" />
  </object>
</model>

Adding works correctly.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vasenin26, 2014-01-08
@vasenin26

You don't have a primary in the schema. Inherit your class from xPDOSimpleObject or specify primary key explicitly

<index alias="name" name="name" primary="false" unique="false" type="BTREE">
    <column key="name" length="" collation="A" null="false" />
</index>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question