Ejemplo n.º 1
0
 function __construct($queryset = false)
 {
     $this->queryset = $queryset;
     if ($queryset) {
         $this->stmt = $queryset->getQuery();
         $connection = Manager::getConnection($this->model);
     }
 }
Ejemplo n.º 2
0
 function getQuery($options = array())
 {
     if (isset($this->query)) {
         return $this->query;
     }
     // Load defaults from model
     $model = $this->model;
     $model::_inspect();
     $query = clone $this;
     $options += $this->options;
     // Be careful not to make local modifications based on model meta
     // compilation preferences
     if ($options['nosort']) {
         $query->ordering = array();
     } elseif (!$query->ordering && $model::getMeta('ordering')) {
         $query->ordering = $model::$meta['ordering'];
     }
     if (false !== $query->related && !$query->values && $model::getMeta('select_related')) {
         $query->related = $model::getMeta('select_related');
     }
     if (!$query->defer && $model::getMeta('defer')) {
         $query->defer = $model::getMeta('defer');
     }
     $class = $options['compiler'] ?: $this->compiler;
     $connection = Manager::getConnection($model);
     $compiler = $connection->getCompiler();
     return $this->query = $compiler->compileSelect($query);
 }
Ejemplo n.º 3
0
 function inspectFields()
 {
     $connection = Manager::getConnection($this);
     $compiler = $connection->getCompiler();
     return $compiler->inspectTable($this['table']);
     // TODO: Support caching the fields
 }