コード例 #1
0
ファイル: Builder.php プロジェクト: lucasnpinheiro/SimpleAR
 /**
  * Return a new Query instance.
  *
  * @param Builder $b The builder to use.
  * @return Query
  */
 public function initQuery(QueryBuilder $b = null, $root = null, $rootAlias = null, $critical = false, $storeIt = false)
 {
     $q = $this->newQuery($b);
     $root = $root ?: $this->_root;
     $q->root($root, $rootAlias ?: $this->_rootAlias);
     $critical && $q->setCriticalQuery($critical);
     $storeIt && $this->setQuery($q);
     if (is_valid_model_class($root)) {
         // delete relation when we make an update query
         if ($b->type == QueryBuilder::UPDATE) {
             $q->conditions($this->_cleanConditionRelation($root::getGlobalConditions()));
         } else {
             $q->conditions($root::getGlobalConditions());
         }
     }
     return $q;
 }
コード例 #2
0
ファイル: Builder.php プロジェクト: lucasnpinheiro/SimpleAR
 /**
  * Set the query root.
  *
  * Component: "root"
  * ----------
  *
  * @param string $root A valid model class name, or a DB table name.
  * @param string $alias An alias for the root. It will override the default
  * that you can find here: @see ::$_rootAlias.
  */
 public function root($root, $alias = null)
 {
     $alias && $this->setRootAlias($alias);
     if (is_valid_model_class($root)) {
         $this->setRootModel($root);
     } else {
         $this->setRootTableName($root);
     }
     return $this;
 }
コード例 #3
0
ファイル: SimpleAR.php プロジェクト: lucasnpinheiro/SimpleAR
 public function registerAutoload(array $directories)
 {
     spl_autoload_register(function ($class) use($directories) {
         foreach ($directories as $path) {
             if (file_exists($file = $path . $class . '.php')) {
                 include $file;
                 // We check two things:
                 //
                 //  1) Class is a subclass of SimpleAR's Model base class:
                 //  it might be an independant class located in the model
                 //  folder.
                 //  2) Class is not abstract: wake up has no sense on
                 //  abstract class.
                 if (is_valid_model_class($class)) {
                     $class::wakeup();
                 }
                 // We have included our model, stop here.
                 break;
             }
         }
     });
 }