public function edit() { $postBuilder = new SqlBuilder(); $post = $postBuilder->from('post')->with(array('status' => array('status_name', 'label', 'id', 'status')))->where(array('id = ' . $_GET['id']))->limit(1)->query(); $tagsBuilder = new SqlBuilder(); $tags = $tagsBuilder->select(array('tag'))->from('tag')->where(array('post_id = ' . $post->id))->query(); $this->render('post/edit', array('post' => $post, 'tags' => $tags)); }
/** * Return the SQL representation of this PdoDataSet * * @return string */ public function toSql() { return $this->sqlBuilder->select(); }
/** * @throws Exception if MySQL error occurs * @return void */ public function execute() { $rs = SqlTools::sqlQuery("SELECT " . SqlBuilder::select($this->tables) . " \nFROM " . SqlBuilder::from($this->get_from_tables()) . SqlBuilder::joins($this->joins, $this->getJoinType()) . "\n" . SqlBuilder::where($this->where, $this->sql_where) . "\n" . SqlBuilder::order_by($this->order, $this->order_dir) . "\n" . SqlBuilder::limit($this->offset, $this->limit)); if ($rs) { $this->load($rs); $this->_executed = true; if (!is_null($this->_foreign_object_waiting_for_association)) { $this->associateForeignObject($this->_foreign_object_waiting_for_association[0], $this->_foreign_object_waiting_for_association[1]); } } else { throw new Exception("Fatal error:" . mysql_error()); } }