I have the following query:
return Doctrine_Query::create()
->from('Model_Article m')
->where($where)
->orderBy($order);
In $where I have this:
$where='m.title='.$name;
The above produces this error:
Message: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'sadsa' in 'where clause'. Failing Query: "SELECT COUNT(*) AS num_results FROM article a WHERE a.title = sadsa"
Why?
Error is because resulting query looks like “** where title=sadsda **”, so SQL engine looks for column named “sadsda”. To prevent it you must mention, that you want to compare with a string, not a column value. You can make it using your engine rules (usually enclose string with “‘”), but it isn’t secure, I think you should use placeholders engine, that doctrine provides, for example