spadefoot / kohana-orm-leap

An ORM module for the Kohana PHP framework that is designed to work with all major databases.
http://spadefoot.github.io/kohana-orm-leap/
100 stars 25 forks source link

WHERE and '<=' Operator #34

Closed CubedEye closed 12 years ago

CubedEye commented 12 years ago

I have just noticed that when using '<=' or DB_SQL_Operator::_LESS_THAN_OR_EQUALTO that it is breaking the statement somewhere along the line. For Example:

DB_SQL::select('default') ->from('table') ->column('id') ->where('time', DB_SQL_OPERATOR::_GREATER_THAN_OR_EQUALTO, time()) ->statement();

Returns the correct statement:

SELECT id FROM table WHERE time >= 1335406644;

This is also the same for <, =, != and >, but when using <= it returns:

SELECT id FROM table WHERE time //No $operator and $value

bluesnowman commented 12 years ago

I am unable to replicate this error. I ran the following:

$statement = DB_SQL::select('default')
    ->from('table')
    ->column('id')
    ->where('time', DB_SQL_Operator::_GREATER_THAN_OR_EQUAL_TO_, time())
    ->statement();
echo $statement;

$statement = DB_SQL::select('default')
    ->from('table')
    ->column('id')
    ->where('time', DB_SQL_Operator::_LESS_THAN_OR_EQUAL_TO_, time())
    ->statement();
echo $statement;

And, I get the following output:

SELECT `id` FROM `table` WHERE `time` >= 1336425639;
SELECT `id` FROM `table` WHERE `time` <= 1336425639;

The default database builder I used was for MySQL. What database are you building your queries for?

Check to make sure that you have the most up-to-date version installed and that your constants are correct. In your examples, it looks like you are missing the underscore. If you find a have a bug fix, I will be happy to merge a pull request.