Exemple #1
0
 /**
  * Constructor method for the adapter.  This constructor implements the setting of the
  * 3 required properties for the object.
  *
  * @param resource $d The datasource resource
  */
 function informixAdapter($d)
 {
     parent::RecordSetAdapter($d);
     $ob = "";
     $fieldcount = ifx_num_fields($d);
     $be = $this->isBigEndian;
     $fc = pack('N', $fieldcount);
     if (ifx_num_rows($d) > 0) {
         $line = ifx_fetch_row($d, "FIRST");
         do {
             //Write inner inner (data) array
             $ob .= "\n" . $fc;
             foreach ($line as $key => $value) {
                 if (is_string($value)) {
                     // string
                     $os = $this->_directCharsetHandler->transliterate($value);
                     $len = strlen($os);
                     if ($len < 65536) {
                         $ob .= "" . pack('n', $len) . $os;
                     } else {
                         $ob .= "\f" . pack('N', $len) . $os;
                     }
                 } elseif (is_float($value) || is_int($value)) {
                     //numberic
                     $b = pack('d', $value);
                     // pack the bytes
                     if ($be) {
                         // if we are a big-endian processor
                         $r = strrev($b);
                     } else {
                         // add the bytes to the output
                         $r = $b;
                     }
                     $ob .= "" . $r;
                 } elseif (is_bool($value)) {
                     //bool
                     $ob .= "" . pack('c', $value);
                 } elseif (is_null($value)) {
                     // null
                     $ob .= "";
                 }
             }
         } while ($line = ifx_fetch_row($d, "NEXT"));
     }
     $this->serializedData = $ob;
     $properties = ifx_fieldproperties($d);
     for ($i = 0; $i < $fieldcount; $i++) {
         $this->columnNames[$i] = $this->_directCharsetHandler->transliterate(key($properties));
         next($properties);
     }
     $this->numRows = ifx_num_rows($d);
 }
Exemple #2
0
 /**
  * Constructor method for the adapter.  This constructor implements the setting of the
  * 3 required properties for the object.
  *
  * @param resource $d The datasource resource
  */
 function informixAdapter($d)
 {
     parent::RecordSetAdapter($d);
     $fieldcount = ifx_num_fields($d);
     $properties = ifx_fieldproperties($d);
     for ($i = 0; $i < $fieldcount; $i++) {
         $this->columns[$i] = key($properties);
         next($properties);
     }
     if (ifx_num_rows($d) > 0) {
         $line = ifx_fetch_row($d, "FIRST");
         do {
             $this->rows[] = $line;
         } while ($line = ifx_fetch_row($d, "NEXT"));
     }
 }
Exemple #3
0
 /**
  * Devuelve el numero de filas de un select
  *
  * @param resource $result_query
  * @return int
  */
 public function num_rows($result_query = '')
 {
     if (!$this->id_connection) {
         return false;
     }
     if (!$result_query) {
         $result_query = $this->last_result_query;
         if (!$result_query) {
             return false;
         }
     }
     if (($number_rows = ifx_num_rows($result_query)) !== false) {
         // Emula un limit a nivel de adaptador
         if ($this->limit == -1) {
             return $number_rows;
         } else {
             return $this->limit < $number_rows ? $this->limit : $number_rows;
         }
     } else {
         throw new KumbiaException($this->error());
     }
     return false;
 }