In MySQL I can just do something like the following:
SELECT * FROM treelist ORDER BY `left` ASC;
but if I try to do the following in Phalcon I get an error:
TreeList::find(['order' => '`left` ASC']);
What's the proper way to escape special keywords like "left" and "right" in PHQL?
Also, some unrelated questions:
- Is Model->afterFetch() broken in 2.0.7 or am I doing something wrong? I tried code which looks similar to the following but it seems afterFetch() wasn't even called (beforeSave() works fine though).
class Robots extends Model
{
public $id;
public $part_id;
public function afterFetch()
{
if (empty($this->part_id))
$this->part_id = -1;
}
}
print_r(Robots::find()->toArray());
- What's the best way to strip tags from all fields before saving model? Should I do something like the following or is there a better way?
public function beforeSave()
{
$filter = new Filter();
$fields = $this->columnMap();
foreach($fields as $field)
$this->{$field} = $filter->sanitize($this->{$field}, "striptags");
}