/** * 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; }
/** * @param PerfORM $model * @param string $from * @return stdClass */ public function getRenameView($model, $from) { return (object) array('view' => $model->getTableName(), 'from' => $from); }
/** * 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()); }