本文整理汇总了PHP中Zend_Db_Select::joinNatural方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Db_Select::joinNatural方法的具体用法?PHP Zend_Db_Select::joinNatural怎么用?PHP Zend_Db_Select::joinNatural使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Db_Select
的用法示例。
在下文中一共展示了Zend_Db_Select::joinNatural方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: joinFrom
/**
* WARNING: Only columns copying supported.
* @param Lib_Model_Db_Mysql $model
* @param string|null $thisKeyCol may contain table prefix or not
* @param string|null $thatKeyCol may contain table prefix or not
* @param string $conditions
* @return $this
*/
public function joinFrom($model, $thisKeyCol, $thatKeyCol = null, $conditions = '')
{
if ($thatKeyCol === null) {
debug_assert($thisKeyCol !== null);
$thatKeyCol = $model->getPrimaryKey();
} elseif ($thisKeyCol === null) {
debug_assert($thatKeyCol !== null);
$thisKeyCol = $this->getPrimaryKey();
}
$this->prefixColumn($model, $thatKeyCol);
$this->prefixColumn($this, $thisKeyCol);
$conditions = str_replace('{that}', $model->getAlias(), $conditions);
$conditions = str_replace('{this}', $this->getAlias(), $conditions);
$this->mapPartWhere($this->addAliasToConditionDg());
$model->mapPartWhere($model->addAliasToConditionDg());
$thisFrom = $this->_select->getPart(Zend_Db_Select::FROM);
$modelColumns = array_chain($model->_select->getPart(Zend_Db_Select::COLUMNS), array_group_dg(array_get_dg(return_dg(0))), array_map_val_dg(array_chain_dg(array_map_val_dg(function ($descriptor) {
return null === $descriptor[2] ? $descriptor[1] : [$descriptor[2] => $descriptor[1]];
}), function ($columns) {
$outArray = [];
array_map_val($columns, function ($column) use(&$outArray) {
if (is_array($column)) {
array_map_val($column, function ($column, $alias) use(&$outArray) {
$outArray[$alias] = $column;
});
} else {
$outArray[] = $column;
}
});
return $outArray;
})));
array_each($model->_select->getPart(Zend_Db_Select::FROM), function ($descriptor, $alias) use($modelColumns, $thisFrom, $model, $thisKeyCol, $thatKeyCol, $conditions) {
debug_enforce(!array_key_exists($alias, $thisFrom), "Alias `{$alias}` already used for table `{$descriptor['tableName']}`");
switch ($descriptor['joinType']) {
case Zend_Db_Select::FROM:
$this->_select->joinLeft([$model->getAlias() => $model->getTable()], "{$thisKeyCol}={$thatKeyCol} " . $conditions, array_key_exists($alias, $modelColumns) ? $modelColumns[$alias] : [], $descriptor['schema']);
break;
case Zend_Db_Select::INNER_JOIN:
$this->_select->joinInner([$alias => $descriptor['tableName']], $descriptor['joinCondition'], array_key_exists($alias, $modelColumns) ? $modelColumns[$alias] : [], $descriptor['schema']);
break;
case Zend_Db_Select::LEFT_JOIN:
$this->_select->joinLeft([$alias => $descriptor['tableName']], $descriptor['joinCondition'], array_key_exists($alias, $modelColumns) ? $modelColumns[$alias] : [], $descriptor['schema']);
break;
case Zend_Db_Select::RIGHT_JOIN:
$this->_select->joinRight([$alias => $descriptor['tableName']], $descriptor['joinCondition'], array_key_exists($alias, $modelColumns) ? $modelColumns[$alias] : [], $descriptor['schema']);
break;
case Zend_Db_Select::FULL_JOIN:
$this->_select->joinFull([$alias => $descriptor['tableName']], $descriptor['joinCondition'], array_key_exists($alias, $modelColumns) ? $modelColumns[$alias] : [], $descriptor['schema']);
break;
case Zend_Db_Select::CROSS_JOIN:
$this->_select->joinCross([$alias => $descriptor['tableName']], $descriptor['joinCondition'], array_key_exists($alias, $modelColumns) ? $modelColumns[$alias] : [], $descriptor['schema']);
break;
case Zend_Db_Select::NATURAL_JOIN:
$this->_select->joinNatural([$alias => $descriptor['tableName']], $descriptor['joinCondition'], array_key_exists($alias, $modelColumns) ? $modelColumns[$alias] : [], $descriptor['schema']);
break;
default:
debug_assert(false, "Unknown join type " . var_dump_human_compact($descriptor['joinType']));
break;
}
});
$this->settingsJoin($model);
return $this;
}