コード例 #1
0
ファイル: Array.php プロジェクト: helenadeus/s3db.map
 /**
  * Reusable static fetch method
  * 
  * Since many drivers end up needing this array driver's features,
  * the following method is provided in order to avoid subclassing
  * this class.
  * 
  * @param   integer $offset     Limit offset (starting from 0)
  * @param   integer $len        Limit length
  * @param   string  $sortField  Field to sort by
  * @param   string  $sortDir    Sort direction : 'ASC' or 'DESC'
  * @static
  */
 function &staticFetch($ar, $fieldList, $offset = 0, $len = null, $sortField = null, $sortDir = 'ASC')
 {
     // sorting
     if ($sortField) {
         Structures_DataGrid_DataSource_Array::sort($sortField, $sortDir, $ar);
     }
     // slicing
     if (is_null($len)) {
         $slice = array_slice($ar, $offset);
     } else {
         $slice = array_slice($ar, $offset, $len);
     }
     // Filter out fields that are to not be rendered
     //
     // With the new array_intersect_key() the following would be :
     // $records = array_intersect_key($slice, array_flip ($fieldList));
     // One line... And faster... But this function is cvs-only.
     $records = array();
     foreach ($slice as $rec) {
         $buf = array();
         foreach ($rec as $key => $val) {
             if (in_array($key, $fieldList)) {
                 $buf[$key] = $val;
             }
         }
         $records[] = $buf;
     }
     return $records;
 }
コード例 #2
0
ファイル: CSV.php プロジェクト: helenadeus/s3db.map
 function Structures_DataGrid_DataSource_CSV()
 {
     parent::Structures_DataGrid_DataSource_Array();
 }
コード例 #3
0
ファイル: DB.php プロジェクト: helenadeus/s3db.map
 /**
  * Fetch
  *
  * @param   integer $offset     Offset (starting from 0)
  * @param   integer $limit      Limit
  * @param   string  $sortField  Field to sort by
  * @param   string  $sortDir    Sort direction : 'ASC' or 'DES     
  * @access  public
  * @return  array       The 2D Array of the records
  */
 function &fetch($offset = 0, $limit = null, $sortField = null, $sortDir = 'ASC')
 {
     $recordSet = array();
     // Fetch the Data
     if ($numRows = $this->_result->numRows()) {
         while ($record = $this->_result->fetchRow(DB_FETCHMODE_ASSOC)) {
             $recordSet[] = $record;
         }
     }
     // Determine fields to render
     if (!$this->_options['fields']) {
         $this->setOptions(array('fields' => array_keys($recordSet[0])));
     }
     // Limit and Sort the Data
     $recordSet =& Structures_DataGrid_DataSource_Array::staticFetch($recordSet, $this->_options['fields'], $offset, $limit, $sortField, $sortDir);
     return $recordSet;
 }
コード例 #4
0
ファイル: XML.php プロジェクト: helenadeus/s3db.map
 /**
  * Constructor
  * 
  */
 function Structures_DataGrid_DataSource_XML()
 {
     parent::Structures_DataGrid_DataSource_Array();
     $this->_addDefaultOptions(array('xpath' => ''));
 }