Skip to content

Instantly share code, notes, and snippets.

@vitorpacheco
Created August 3, 2012 20:40
Show Gist options
  • Select an option

  • Save vitorpacheco/3251320 to your computer and use it in GitHub Desktop.

Select an option

Save vitorpacheco/3251320 to your computer and use it in GitHub Desktop.
<?php
class AppModel extends Model {
public function getQuery($type, $options = array()) {
$dbo = $this->getDataSource();
$defaults = array(
'fields' => array('`' . $this->alias . '`.`*`'),
'table' => '"' . $dbo->config['schema'] . '".' . $dbo->fullTableName($this),
'alias' => $this->alias,
'limit' => null,
'offset' => null,
'joins' => array(),
'conditions' => array(),
'order' => array(),
'group' => array(),
);
$options = array_merge($defaults, $options);
$query = $dbo->buildStatement($options, $this->{$this->alias});
return $query;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment