本文整理汇总了PHP中Zend_Db_Table_Select::joinLeft方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Db_Table_Select::joinLeft方法的具体用法?PHP Zend_Db_Table_Select::joinLeft怎么用?PHP Zend_Db_Table_Select::joinLeft使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Db_Table_Select
的用法示例。
在下文中一共展示了Zend_Db_Table_Select::joinLeft方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addAutoJoin
protected function addAutoJoin(Zend_Db_Table_Select $select)
{
$tables = array();
$columns = array();
$references = $this->getDefaultAdapter()->getReferences(null, $this->_name);
if ($references) {
foreach ($references as $key => $reference) {
$tableName = $reference['table'];
$table = new La_Db_Table($tableName);
$columnName = $table->getNameForOptionField();
$comments = $this->getComments();
$column = $reference['columns'];
$columnAlias = $comments[$column];
$tableAlias = $tableName . $key;
$columns[$columnAlias] = $tableAlias . '.' . $columnName;
$tables[$tableName] = $tableName;
$joinTable = array($tableAlias => $tableName);
$condition = sprintf('`%s`.`id` = `%s`.`%s`', $tableAlias, $this->_name, $column);
$select->joinLeft($joinTable, $condition, array());
}
$select->setIntegrityCheck(false)->columns($columns);
}
return $select;
}
示例2: _addJoinQuery
/**
* Add some data from other table, tests the joinTables
* property. If not empty add tables and join clauses.
*
* @param Zend_Db_Table_Select $select
* @param array $params
*
* @return Zend_Db_Table_Select
*/
private function _addJoinQuery($select, array $params = array())
{
if (isset($params['joinTables']) && count($params['joinTables'])) {
$this->_joinTables = $params['joinTables'];
}
/* If needs to add some data from other table, tests the joinTables
* property. If not empty add tables and join clauses.
*/
if (count($this->_joinTables) > 0) {
// Get the constraint attribute = foreign key to link tables.
$constraint = $params['constraint'];
// Loop on tables list(given by object class) to build the query
foreach ($this->_joinTables as $key => $object) {
//Create an object and fetch data from object.
$tmpObject = new $object();
$tmpDataTable = $tmpObject->getDataTableName();
$tmpIndexTable = $tmpObject->getIndexTableName();
$tmpColumnData = $tmpObject->getDataColumns();
$tmpColumnIndex = $tmpObject->getIndexColumns();
//Add data to tables list
$tables[$tmpDataTable] = $tmpColumnData;
$tables[$tmpIndexTable] = $tmpColumnIndex;
//Get the primary key of the first data object to join table
$tmpDataId = $tmpObject->getDataId();
// If it's the first loop, join first table to the current table
if ($key == 0) {
$select->joinLeft($tmpDataTable, $tmpDataId . ' = ' . $constraint);
//If there's an index table then it too and filter according language
if (!empty($tmpIndexTable)) {
$tmpIndexId = $tmpObject->getIndexId();
$select->joinLeft($tmpIndexTable, $tmpDataId . ' = ' . $tmpIndexId);
$select->where($tmpObject->getIndexLanguageId() . ' = ?', $this->_defaultEditLanguage);
}
/* If there's more than one table to link, store the current
* table name for the next loop
*/
if (count($this->_joinTables) > 1) {
$prevConstraint = $tmpObject->getConstraint();
}
} elseif ($key > 0) {
// We have an other table to join to previous.
$tmpDataId = $tmpObject->getDataId();
$select->joinLeft($tmpDataTable, $prevConstraint . ' = ' . $tmpDataId);
if (!empty($tmpIndexTable)) {
$tmpIndexId = $tmpObject->getIndexId();
$select->joinLeft($tmpIndexTable, $constraint . ' = ' . $tmpIndexId);
$select->where($tmpObject->getIndexLanguageId() . ' = ?', $this->_defaultEditLanguage);
}
}
}
}
return $select;
}
示例3: orderByTitleMain
/**
* Ordering to be applied on the result set.
*
* @param boolean $order Sort ascending if true, descending otherwise.
* @return Opus_DocumentFinder Fluent interface.
*/
public function orderByTitleMain($order = true)
{
$this->select->joinLeft(array('t' => 'document_title_abstracts'), 't.document_id = d.id AND t.type = "main"', array())->group('d.id')->order('t.value ' . ($order ? 'ASC' : 'DESC'));
return $this;
}