W
W
WotanWeb2020-02-21 19:20:15
MODX
WotanWeb, 2020-02-21 19:20:15

Why doesn't modx's save() method work on an existing object?

Hi everybody! Can you please tell me why the save() method does not work for an existing object, although it works for a new one?
I try like this:

$test = $modx->getObject('LjValues', ['order_id' => 3, 'field_id' => 1]);
echo $test->get('value');
$test->set('value', "тестовый тест");
if($test->save() === true){
    echo $test->get('value');
}

And everything seems to be fine, it displays the old value first, then in $test->save() === true, displays the new value. But the database remains old, the log is silent.

Scheme:
<object class="LjValues" table="lj_values" extends="xPDOSimpleObject">
  <field key="field_id" dbtype="int" precision="11" phptype="integer" null="false" />
  <field key="value" dbtype="varchar" precision="191" phptype="string" null="false" />
  <field key="order_id" dbtype="int" precision="11" phptype="integer" null="false" />
  <aggregate alias="LjFields" class="LjFields" local="field_id" foreign="id" cardinality="one" owner="foreign" />
  <aggregate alias="LjOrders" class="LjOrders" local="order_id" foreign="id" cardinality="one" owner="foreign" />
</object>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WotanWeb, 2020-02-21
@WotanWeb

God, I don't know why, but LjValues ​​is a bad name. Just renamed to LjFieldvalue - everything is amazing.
And a table in modx_lj_fieldvalue.
xPDO I love you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question