示例#1
0
文件: QuerySet.php 项目: Edke/PerfORM
 /**
  * Getter for datasource
  * @return DibiDataSource
  */
 public function getDataSource()
 {
     if (!$this->dataSource) {
         # build query
         $query = array();
         $query[] = "\nSELECT";
         $this->addFields($this->model);
         $query[] = implode(",\n", $this->fields);
         $query[] = sprintf("FROM \"%s\"", $this->model->getTableName());
         $this->addJoins($this->model);
         $query[] = implode("\n", $this->joins);
         $this->dataSource = new DibiDataSource(implode("\n", $query), PerfORMController::getConnection());
     }
     return $this->dataSource;
 }
示例#2
0
 /**
  * @param PerfORM $model
  * @param string $from
  * @return stdClass
  */
 public function getRenameView($model, $from)
 {
     return (object) array('view' => $model->getTableName(), 'from' => $from);
 }
示例#3
0
 /**
  * Update model in storage, sets hashes for it's model
  * @param PerfORM $model
  */
 public function updateModelSync($model)
 {
     $this->query('update [tables] set [hash] = %s where [name] = %s', $model->getHash(), $model->getTableName());
 }