當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Db_Table_Select::getPart方法代碼示例

本文整理匯總了PHP中Zend_Db_Table_Select::getPart方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Db_Table_Select::getPart方法的具體用法?PHP Zend_Db_Table_Select::getPart怎麽用?PHP Zend_Db_Table_Select::getPart使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_Db_Table_Select的用法示例。


在下文中一共展示了Zend_Db_Table_Select::getPart方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: parseSelect

 private function parseSelect(\Zend_Db_Table_Select $select)
 {
     $return = array();
     foreach ($select->getPart('columns') as $c) {
         if ($c[1] instanceof \Zend_Db_Expr) {
             $return[] = $c[1];
         } elseif ($c[1] == '*') {
             foreach ($this->table->info(\Zend_Db_Table_Abstract::COLS) as $col) {
                 $return[] = '`' . $c[0] . '`.`' . $col . '`';
             }
         } else {
             $return[] = '`' . $c[0] . '`.`' . $c[1] . '`';
         }
     }
     return $return;
 }
開發者ID:abbert,項目名稱:datagrid,代碼行數:16,代碼來源:ZendDbSource.php

示例2: direct

 /**
  * Get DataTable data
  *
  * @param Zend_Db_Table_Select $select
  * @param array|null $columns
  * @return array
  */
 public function direct(Zend_Db_Table_Select $select, $columns = null)
 {
     $table = $select->getTable();
     if (!$columns) {
         $columns = $table->info(Zend_Db_Table_Abstract::COLS);
     }
     $colCount = count($columns);
     $request = $this->getRequest();
     /*
      * Ordering
      */
     if (null !== $request->getParam('iSortCol_0', null)) {
         for ($i = 0, $l = $request->getParam('iSortingCols'); $i < $l; $i++) {
             if ($request->getParam('bSortable_' . (int) $request->getParam('iSortCol_' . $i))) {
                 $select->order($columns[(int) $request->getParam('iSortCol_' . $i)] . " " . $request->getParam('sSortDir_' . $i));
             }
         }
     }
     /*
      * Filtering
      * NOTE this does not match the built-in DataTables filtering which does it
      * word by word on any field. It's possible to do here, but concerned about efficiency
      * on very large tables, and MySQL's regex functionality is very limited
      */
     if ($search = $request->getParam('sSearch')) {
         for ($i = 0; $i < $colCount; $i++) {
             $select->orHaving("{$columns[$i]} LIKE ?", '%' . $search . '%');
         }
     }
     /* Individual column filtering */
     for ($i = 0; $i < $colCount; $i++) {
         if ($request->getParam('bSearchable_' . $i) == "true") {
             if ($search = $request->getParam('sSearch_' . $i)) {
                 $select->having("{$columns[$i]} LIKE ?", '%' . $search . '%');
             }
         }
     }
     //save current query for fetching data
     $query = clone $select;
     $tableName = $table->info(Zend_Db_Table::NAME);
     $expr = new Zend_Db_Expr('COUNT(*) as total');
     /* Data set length after filtering */
     if ($select->getPart(Zend_Db_Select::FROM)) {
         $select->columns($expr);
     } else {
         $select->from($tableName, $expr);
     }
     /* Data no result */
     if ($iFilteredTotal = $table->fetchRow($select)) {
         $iFilteredTotal = $iFilteredTotal->total;
     } else {
         $iFilteredTotal = 0;
     }
     $query->limit($request->getParam('iDisplayLength'), $request->getParam('iDisplayStart'));
     /*
      * SQL queries
      * Get data to display
      */
     if ($query->getPart(Zend_Db_Select::FROM)) {
         $query->columns($columns);
     } else {
         $query->from($tableName, $columns);
     }
     // Get total rows count
     $select = $table->select()->from($tableName, $expr);
     $iTotalRecords = $table->fetchRow($select)->total;
     return array("sEcho" => (int) $request->getParam('sEcho'), "aaData" => $table->fetchAll($query)->toArray(), "iTotalRecords" => $iTotalRecords, "iTotalDisplayRecords" => $iFilteredTotal);
 }
開發者ID:shahmaulik,項目名稱:zfcore,代碼行數:75,代碼來源:DataTables.php


注:本文中的Zend_Db_Table_Select::getPart方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。