Hi Alex,
if you paste code, enclose it in ``` (not displayed):
function test()
{
something();
}
Api\Storage class works by default only with 2 tables, one for data of the main object and one for custom-fields. If you need more tables, automatic quoting fails with the error-message you gave, eg:
$where = [
'main_something' => 'some-value',
'other_something' => 'other-value',
];
Columns with ‘main_’ prefix are in the table Api\Storage is instanciated for, the ones with ‘other_’ prefix are from an other table.
What you can do is:
$where = [
'main_something' => 'some-value',
$this->db->expression('other_table', ['other_something' => 'other-value']),
];
Of cause you can also reimplement eg. search method, to understand and automatic to the right thing for ‘other_table’, eg.:
class my_class extends Api\Storage
{
const OTHER_TABLE = 'other_table';
const OTHER_PREFIX = 'other_';
const OTHER_PREFIX_LEN = 6;
function search($criteria, $only_keys=True ,$order_by='', $extra_cols='', $wildcard='', $empty=False, $op='AND', $start=false, $filter=null)
{
if (!is_array($filter)) $filter = $filter ? (array)$filter : [];
foreach($filter as $col => $value)
{
if (!is_int($col) && substr($col, 0, self::OTHER_PREFIX_LEN) === self::OTHER_PREFIX)
{
$filter[] = $this->db->expression(self::OTHER_TABLE, [$col => $value]);
unset($filter[$col];
}
}
return parent::search($criteria, $only_keys ,$order_by, $extra_cols, $wildcard, $empty, $op, $start, $filter);
}
}
Most of our more complex apps, do something similar.
Ralf