コード例 #1
0
	public function activate()
	{
		if ($this->_list !== null) {return false;}
		
		list ($qs, $args) = $this->getSQLQuery();
		$q = DB::prepare($qs);
		$q->execute($args);
		$this->_list = array();
		$this->rewind();
		foreach ($q->fetchAll() as $row)
		{
			$this->_list[] = DBModel::fetch($row, $this->_from);
		}
		return true;
	}
コード例 #2
0
	protected function fetch($row)
	{
		return DBModel::fetch($row, $this->_table);
	}
コード例 #3
0
	public function activate()
	{
		if ($this->_list !== null) {return false;}
		
		$this->_list = array();
		
		$joins = array();
		foreach ($this->_tableOtherKeys as $key => $other)
		{
			$joins[] = $this->_table.'.'.$other .'='.$this->_otherName.'.'.$this->_otherKeys[$key];
		}
		$wheres = array();
		$args = array();
		foreach ($this->_tableThisKeys as $key => $tableKey)
		{
			$wheres[] = $this->_table.'.'.$tableKey.'=:'.$tableKey;
			$keyName = $this->_thisKeys[$key].'_db';
			$args[':'.$tableKey] = $this->_instance->$keyName;
		}
		
		$query = 'SELECT '.$this->_otherName.'.* FROM ' . $this->_table.
		            ' JOIN ' . $this->_otherName.' ON '. implode(', ', $joins) . 
		            ' WHERE ' . implode (' AND ', $wheres);
		$q = DB::prepare($query);
		$q->execute($args);
		
		foreach ($q->fetchAll() as $row)
		{
			$this->_list[] = DBModel::fetch($row, $this->_otherName);
		}
		$this->rewind();
		return true;
	}
コード例 #4
0
ファイル: sortable.class.php プロジェクト: nathansamson/CoOrg
	private function retrieve($args)
	{
		list($queryExpressions, $queryArgs) = $this->params($args);
		
		$q = DB::prepare('SELECT * FROM ' . $this->_class.
		   ' WHERE ' . implode(' AND ', $queryExpressions) . 
		   ' ORDER BY sequence');
		$q->execute($queryArgs);
		
		$res = array();
		foreach ($q->fetchAll() as $row)
		{
			$res[] = DBModel::fetch($row, $this->_class);
		}
		return $res;
	}