当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Db_Table_Select::joinLeft方法代码示例

本文整理汇总了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;
 }
开发者ID:abdala,项目名称:la,代码行数:24,代码来源:Table.php

示例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;
 }
开发者ID:anunay,项目名称:stentors,代码行数:62,代码来源:ReferencesController.php

示例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;
 }
开发者ID:alexukua,项目名称:opus4,代码行数:11,代码来源:DocumentFinder.php


注:本文中的Zend_Db_Table_Select::joinLeft方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。