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

Oracle - using the ->where on a select breaks statement #18

Closed ekarlso closed 12 years ago

ekarlso commented 12 years ago

$select->where("BELONGS_TO", "=", "X");

$select->page($this->page_offset, $this->page_limit); $select->where("BELONGS_TO", "=", "u333v"); $select->order_by($this->sort_column, $this->sort_direction);

This produced a SQL statement like:

SELECT * FROM (SELECT * FROM "SERVERS" WHERE "BELONGS_TO" = 0x7533333376 ORDER BY "SERVER" DESC) WHERE ROWNUM <= 20;

I think the 0x?.. there breaks the SELECT no?

Maybe some kind of error with the builder?

ekarlso commented 12 years ago

So I found out that it's the expression buklder that apparantly breaks this when it does: return DB_Connection_Pool::instance()->get_connection($this->source)->escape_string($expr);

spadefoot commented 12 years ago

Ok, I will look into fixing this error in the Oracle plugin.

spadefoot commented 12 years ago

With some minor refactoring of the code, I am working on a solution based on the following article: http://www.orafaq.com/faq/how_does_one_escape_special_characters_when_writing_sql_queries.

spadefoot commented 12 years ago

Just improved the escape string function. Please note that the function has been renamed from escape_string($string) to quote($string, $like = FALSE).