Welcome Guest, Not a member yet? Register   Sign In
Gas Orm SQL Query

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:

<?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! Smile

Messages In This Thread
Gas Orm SQL Query - by El Forum - 04-02-2012, 08:14 PM
Gas Orm SQL Query - by El Forum - 04-07-2012, 08:07 AM

Theme © iAndrew 2016 - Forum software by © MyBB