XF 2.2 Question about $finder where - not equal columns

Scandal

Well-known member
I have meet a strange issue via using of the finder of my own Entity.

More specifically, let's say we have these columns on a db table:
id (int)
column1 (int)
column2 (int)

I need during selection to exclude rows for which column1 = column2 (same value).

So I did this:
$finder->where('column1', '!=', 'column2')

But it doesn't seem to work.
Any idea?
 
The SQL that this would output would be:

PHP:
WHERE `column1` != 'column2'

The second column will be treated as a string, it won't know to treat it as a raw column.

XF\Mvc\Entity\Finder has whereSql($sql) and expression($sqlExpression), you should be able to use one of these to pass a raw SQL string through (i.e. `column1` != `column2`)
 
Back
Top Bottom