I'm trying to use buildFromSQL to get a paginated record set. The test code is as follows:
...
$sql = "SELECT * FROM groups g
JOIN user_groups u ON u.id_group = g.id
WHERE u.id_user = $id
ORDER BY $col $dir LIMIT " . PAGE_LINES . " OFFSET $offset";
$groups = fRecordSet::buildFromSQL('Group', $sql);
...
This code results in a SQL query such as:
SELECT * FROM groups g JOIN user_groups u ON u.id_group = g.id WHERE u.id_user = 1 ORDER BY groupname asc LIMIT 25 OFFSET 0;
The query runs fine on console. However, running the test script I get the following error:
Fatal error: Uncaught exception 'fProgrammerException' with message 'The column specified, id_user, does not exist in the table groups' in /usr/local/share/php/flourish/fSchema.php:2201
Stack trace:
#0 /usr/local/share/php/flourish/fORM.php(647): fSchema->getColumnInfo('groups', 'id_user', 'type')
#1 /usr/local/share/php/flourish/fActiveRecord.php(1942): fORM::objectify('Group', 'id_user', '1')
#2 /usr/local/share/php/flourish/fActiveRecord.php(1125): fActiveRecord->loadFromResult(Object(fResult))
#3 /usr/local/share/php/flourish/fRecordSet.php(492): fActiveRecord->__construct(Object(fResult))
#4 /usr/local/share/php/flourish/fRecordSet.php(349): fRecordSet->__construct('Group', Object(fResult), NULL)
I don't know why it's looking for 'id_user' column in the 'groups' table. Am I missing some specific Flourish syntax for SQL queries?
Thanks in advance, A.