[eluser]Unknown[/eluser]
I have a query that is a little too complex to write using the query builder.
Is it possible to run a raw SQL query, and still have it A) protect against SQL injection and B) map properly to the Model?
This is an example of what I'm trying to do:
Code:
<?php namespace Model;
use \Gas\Core;
use \Gas\ORM;
class Title extends ORM {
public $table = 'movie';
public $primary_key = 'id';
function _init()
{
// Relationship definition
// Field definition
self::$fields = array(
'id' => ORM::field('auto'),
'name' => ORM::field('char[255]'),
'year' => ORM::field('char[4]'),
'created' => ORM::field('int[11]'),
'modified' => ORM::field('int[11]'),
);
}
public function search($command) {
return self::query("select * from movie where title like '%".$command['term']."%' limit 10");
}
}
Thanks!