protected function createJoins($val, $inner = FALSE) { $driver = $this->connection->getSupplementalDriver(); $reflection = $this->connection->getDatabaseReflection(); $joins = array(); preg_match_all('~\\b([a-z][\\w.:]*[.:])([a-z]\\w*)(\\s+IS\\b|\\s*<=>)?~i', $val, $matches); foreach ($matches[1] as $names) { $parent = $this->name; if ($names !== "{$parent}.") { // case-sensitive preg_match_all('~\\b([a-z][\\w]*)([.:])~', $names, $matches, PREG_SET_ORDER); foreach ($matches as $match) { list(, $name, $delimiter) = $match; if ($delimiter === ':') { list($table, $primary) = $reflection->getHasManyReference($parent, $name); $column = $reflection->getPrimary($parent); } else { list($table, $column) = $reflection->getBelongsToReference($parent, $name); $primary = $reflection->getPrimary($table); } $joins[$name] = ' ' . (!isset($joins[$name]) && $inner && !isset($match[3]) ? 'INNER' : 'LEFT') . ' JOIN ' . $driver->delimite($table) . ($table !== $name ? ' AS ' . $driver->delimite($name) : '') . ' ON ' . $driver->delimite($parent) . '.' . $driver->delimite($column) . ' = ' . $driver->delimite($name) . '.' . $driver->delimite($primary); $parent = $name; } } } return $joins; }
/** * Creates filtered table representation. * * @param string database table name * @param Nette\Database\Connection */ public function __construct($table, Nette\Database\Connection $connection) { $this->name = $table; $this->connection = $connection; $this->primary = $connection->getDatabaseReflection()->getPrimary($table); $this->sqlBuilder = new SqlBuilder($this); }
function __construct($table, Nette\Database\Connection $connection) { $this->name = $table; $this->connection = $connection; $this->primary = $connection->getDatabaseReflection()->getPrimary($table); $this->delimitedName = $this->tryDelimite($this->name); $this->delimitedPrimary = $connection->getSupplementalDriver()->delimite($this->primary); }
implements\Iterator,\ArrayAccess,\Countable{protected$connection;protected$name;protected$primary;protected$rows;protected$data;protected$select=array();protected$where=array();protected$conditions=array();protected$parameters=array();protected$order=array();protected$limit=NULL;protected$offset=NULL;protected$group='';protected$having='';protected$checkReferenceNewKeys=FALSE;protected$referenced=array();protected$referencing=array();protected$accessed;protected$prevAccessed;protected$keys=array();protected$delimitedName;protected$delimitedPrimary;function __construct($table,Nette\Database\Connection$connection){$this->name=$table;$this->connection=$connection;$this->primary=$connection->getDatabaseReflection()->getPrimary($table);$this->delimitedName=$this->tryDelimite($this->name);$this->delimitedPrimary=$connection->getSupplementalDriver()->delimite($this->primary);}function