コード例 #1
0
ファイル: fbsqlAdapter.php プロジェクト: ksecor/civicrm
 /**
  * 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 pgsqlAdapter($d)
 {
     parent::RecordSetAdapter($d);
     $fieldcount = fbsql_num_fields($d);
     $ob = "";
     $be = $this->isBigEndian;
     $fc = pack('N', $fieldcount);
     if (fbsql_num_rows($d) > 0) {
         fbsql_data_seek($d, 0);
         while ($line = fbsql_fetch_row($d)) {
             // write all of the array elements
             $ob .= "\n" . $fc;
             foreach ($line as $value) {
                 // write all of the array elements
                 if (is_string($value)) {
                     // type as string
                     $os = $this->_directCharsetHandler->transliterate($value);
                     //string flag, string length, and string
                     $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)) {
                     // type as double
                     $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)) {
                     //type as bool
                     $ob .= "";
                     $ob .= pack('c', $value);
                 } elseif (is_null($value)) {
                     // null
                     $ob .= "";
                 }
             }
         }
     }
     $this->serializedData = $ob;
     $this->numRows = fbsql_num_rows($d);
     for ($i = 0; $i < $fieldcount; $i++) {
         $this->columnNames[$i] = $this->_charsetHandler->transliterate(fbsql_field_name($d, $i));
     }
 }
コード例 #2
0
ファイル: fbsqlAdapter.php プロジェクト: FalconGT/DrEvony
 /**
  * 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 fbsqlAdapter($d)
 {
     parent::RecordSetAdapter($d);
     $fieldcount = fbsql_num_fields($d);
     for ($i = 0; $i < $fieldcount; $i++) {
         $this->columns[] = fbsql_field_name($d, $i);
     }
     if (fbsql_num_rows($d) > 0) {
         fbsql_data_seek($d, 0);
         while ($line = fbsql_fetch_row($d)) {
             $this->rows[] = $line;
         }
     }
 }
コード例 #3
0
 function _initrs()
 {
     global $ADODB_COUNTRECS;
     $this->_numOfRows = $ADODB_COUNTRECS ? @fbsql_num_rows($this->_queryID) : -1;
     $this->_numOfFields = @fbsql_num_fields($this->_queryID);
 }
コード例 #4
0
ファイル: fbsql.php プロジェクト: Dulciane/jaws
 /**
  * Returns information about a table or a result set
  *
  * @param object|string  $result  MDB2_result object from a query or a
  *                                 string containing the name of a table.
  *                                 While this also accepts a query result
  *                                 resource identifier, this behavior is
  *                                 deprecated.
  * @param int            $mode    a valid tableInfo mode
  *
  * @return array  an associative array with the information requested.
  *                 A MDB2_Error object on failure.
  *
  * @see MDB2_Driver_Common::tableInfo()
  */
 function tableInfo($result, $mode = null)
 {
     if (is_string($result)) {
         return parent::tableInfo($result, $mode);
     }
     $db =& $this->getDBInstance();
     if (MDB2::isError($db)) {
         return $db;
     }
     $resource = MDB2::isResultCommon($result) ? $result->getResource() : $result;
     if (!is_resource($resource)) {
         return $db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'Could not generate result resource', __FUNCTION__);
     }
     if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
         if ($db->options['field_case'] == CASE_LOWER) {
             $case_func = 'strtolower';
         } else {
             $case_func = 'strtoupper';
         }
     } else {
         $case_func = 'strval';
     }
     $count = @fbsql_num_fields($resource);
     $res = array();
     if ($mode) {
         $res['num_fields'] = $count;
     }
     for ($i = 0; $i < $count; $i++) {
         $res[$i] = array('table' => $case_func(@fbsql_field_table($resource, $i)), 'name' => $case_func(@fbsql_field_name($resource, $i)), 'type' => @fbsql_field_type($resource, $i), 'length' => @fbsql_field_len($resource, $i), 'flags' => @fbsql_field_flags($resource, $i));
         // todo: implement $db->datatype->mapNativeDatatype();
         $res[$i]['mdb2type'] = $res[$i]['type'];
         if ($mode & MDB2_TABLEINFO_ORDER) {
             $res['order'][$res[$i]['name']] = $i;
         }
         if ($mode & MDB2_TABLEINFO_ORDERTABLE) {
             $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
         }
     }
     return $res;
 }
コード例 #5
0
ファイル: fbsql.php プロジェクト: roojs/pear
 /**
  * Returns information about a table or a result set
  *
  * @param object|string  $result  DB_result object from a query or a
  *                                 string containing the name of a table.
  *                                 While this also accepts a query result
  *                                 resource identifier, this behavior is
  *                                 deprecated.
  * @param int            $mode    a valid tableInfo mode
  *
  * @return array  an associative array with the information requested.
  *                 A DB_Error object on failure.
  *
  * @see DB_common::tableInfo()
  */
 function tableInfo($result, $mode = null)
 {
     if (is_string($result)) {
         /*
          * Probably received a table name.
          * Create a result resource identifier.
          */
         $id = @fbsql_list_fields($this->dsn['database'], $result, $this->connection);
         $got_string = true;
     } elseif (isset($result->result)) {
         /*
          * Probably received a result object.
          * Extract the result resource identifier.
          */
         $id = $result->result;
         $got_string = false;
     } else {
         /*
          * Probably received a result resource identifier.
          * Copy it.
          * Deprecated.  Here for compatibility only.
          */
         $id = $result;
         $got_string = false;
     }
     if (!is_resource($id)) {
         return $this->fbsqlRaiseError(DB_ERROR_NEED_MORE_DATA);
     }
     if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE) {
         $case_func = 'strtolower';
     } else {
         $case_func = 'strval';
     }
     $count = @fbsql_num_fields($id);
     $res = array();
     if ($mode) {
         $res['num_fields'] = $count;
     }
     for ($i = 0; $i < $count; $i++) {
         $res[$i] = array('table' => $case_func(@fbsql_field_table($id, $i)), 'name' => $case_func(@fbsql_field_name($id, $i)), 'type' => @fbsql_field_type($id, $i), 'len' => @fbsql_field_len($id, $i), 'flags' => @fbsql_field_flags($id, $i));
         if ($mode & DB_TABLEINFO_ORDER) {
             $res['order'][$res[$i]['name']] = $i;
         }
         if ($mode & DB_TABLEINFO_ORDERTABLE) {
             $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
         }
     }
     // free the result only if we were called on a table
     if ($got_string) {
         @fbsql_free_result($id);
     }
     return $res;
 }
コード例 #6
0
ファイル: fbsql.php プロジェクト: GeekyNinja/LifesavingCAD
 /**
  * Returns information about a table or a result set.
  *
  * @param object|string  $result  MDB2_result object from a query or a
  *                                string containing the name of a table
  * @param int            $mode    a valid tableInfo mode
  * @return array  an associative array with the information requested
  *                or an error object if something is wrong
  * @access public
  * @internal
  * @see MDB2_Driver_Common::tableInfo()
  */
 function tableInfo($result, $mode = null)
 {
     $db =& $GLOBALS['_MDB2_databases'][$this->db_index];
     if ($db->options['portability'] & MDB2_PORTABILITY_LOWERCASE) {
         $case_func = 'strtolower';
     } else {
         $case_func = 'strval';
     }
     if (is_string($result)) {
         /*
          * Probably received a table name.
          * Create a result resource identifier.
          */
         if (MDB2::isError($connect = $db->connect())) {
             return $connect;
         }
         $id = @fbsql_list_fields($db->database_name, $result, $db->connection);
         $got_string = true;
     } else {
         /*
          * Probably received a result object.
          * Extract the result resource identifier.
          */
         $id = $result->getResource();
         if (empty($id)) {
             return $db->raiseError();
         }
         $got_string = false;
     }
     if (!is_resource($id)) {
         return $db->raiseError(MDB2_ERROR_NEED_MORE_DATA);
     }
     $count = @fbsql_num_fields($id);
     // made this IF due to performance (one if is faster than $count if's)
     if (!$mode) {
         for ($i = 0; $i < $count; $i++) {
             $res[$i]['table'] = $case_func(@fbsql_field_table($id, $i));
             $res[$i]['name'] = $case_func(@fbsql_field_name($id, $i));
             $res[$i]['type'] = @fbsql_field_type($id, $i);
             $res[$i]['len'] = @fbsql_field_len($id, $i);
             $res[$i]['flags'] = @fbsql_field_flags($id, $i);
         }
     } else {
         // full
         $res["num_fields"] = $count;
         for ($i = 0; $i < $count; $i++) {
             $res[$i]['table'] = $case_func(@fbsql_field_table($id, $i));
             $res[$i]['name'] = $case_func(@fbsql_field_name($id, $i));
             $res[$i]['type'] = @fbsql_field_type($id, $i);
             $res[$i]['len'] = @fbsql_field_len($id, $i);
             $res[$i]['flags'] = @fbsql_field_flags($id, $i);
             if ($mode & MDB2_TABLEINFO_ORDER) {
                 $res['order'][$res[$i]['name']] = $i;
             }
             if ($mode & MDB2_TABLEINFO_ORDERTABLE) {
                 $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
             }
         }
     }
     // free the result only if we were called on a table
     if ($got_string) {
         @fbsql_free_result($id);
     }
     return $res;
 }
コード例 #7
0
ファイル: adodb-fbsql.inc.php プロジェクト: joeymetal/v1
	function _initrs()
	{
	GLOBAL $ADODB_COUNTRECS;
		$this->_numOfRows = ($ADODB_COUNTRECS) ? @fbsql_num_rows($this->_queryID):-1;
		$this->_numOfFields = @fbsql_num_fields($this->_queryID);
	}
コード例 #8
0
ファイル: fbsql.php プロジェクト: ajisantoso/kateglo
 /**
  * Returns information about a table or a result set
  *
  * @param object|string  $result  MDB2_result object from a query or a
  *                                 string containing the name of a table.
  *                                 While this also accepts a query result
  *                                 resource identifier, this behavior is
  *                                 deprecated.
  * @param int            $mode    a valid tableInfo mode
  *
  * @return array  an associative array with the information requested.
  *                 A MDB2_Error object on failure.
  *
  * @see MDB2_Driver_Common::tableInfo()
  */
 function tableInfo($result, $mode = null)
 {
     $db =& $this->getDBInstance();
     if (PEAR::isError($db)) {
         return $db;
     }
     if (is_string($result)) {
         /*
          * Probably received a table name.
          * Create a result resource identifier.
          */
         $connection = $db->getConnection();
         if (PEAR::isError($connection)) {
             return $connection;
         }
         $id = @fbsql_list_fields($db->database_name, $result, $connection);
         $got_string = true;
     } elseif (MDB2::isResultCommon($result)) {
         /*
          * Probably received a result object.
          * Extract the result resource identifier.
          */
         $id = $result->getResource();
         $got_string = false;
     } else {
         /*
          * Probably received a result resource identifier.
          * Copy it.
          * Deprecated.  Here for compatibility only.
          */
         $id = $result;
         $got_string = false;
     }
     if (!is_resource($id)) {
         return $db->raiseError(MDB2_ERROR_NEED_MORE_DATA);
     }
     if ($db->options['portability'] & MDB2_PORTABILITY_FIX_CASE) {
         if ($db->options['field_case'] == CASE_LOWER) {
             $case_func = 'strtolower';
         } else {
             $case_func = 'strtoupper';
         }
     } else {
         $case_func = 'strval';
     }
     $count = @fbsql_num_fields($id);
     $res = array();
     if ($mode) {
         $res['num_fields'] = $count;
     }
     for ($i = 0; $i < $count; $i++) {
         $res[$i] = array('table' => $case_func(@fbsql_field_table($id, $i)), 'name' => $case_func(@fbsql_field_name($id, $i)), 'type' => @fbsql_field_type($id, $i), 'length' => @fbsql_field_len($id, $i), 'flags' => @fbsql_field_flags($id, $i));
         // todo: implement $db->datatype->mapNativeDatatype();
         $res[$i]['mdb2type'] = $res[$i]['type'];
         if ($mode & MDB2_TABLEINFO_ORDER) {
             $res['order'][$res[$i]['name']] = $i;
         }
         if ($mode & MDB2_TABLEINFO_ORDERTABLE) {
             $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
         }
     }
     // free the result only if we were called on a table
     if ($got_string) {
         @fbsql_free_result($id);
     }
     return $res;
 }
コード例 #9
0
ファイル: fbsql.php プロジェクト: BackupTheBerlios/e-maku-svn
 function tableInfo($result, $mode = null)
 {
     $count = 0;
     $id = 0;
     $res = array();
     /*
      * depending on $mode, metadata returns the following values:
      *
      * - mode is false (default):
      * $result[]:
      *   [0]["table"]  table name
      *   [0]["name"]   field name
      *   [0]["type"]   field type
      *   [0]["len"]    field length
      *   [0]["flags"]  field flags
      *
      * - mode is DB_TABLEINFO_ORDER
      * $result[]:
      *   ["num_fields"] number of metadata records
      *   [0]["table"]  table name
      *   [0]["name"]   field name
      *   [0]["type"]   field type
      *   [0]["len"]    field length
      *   [0]["flags"]  field flags
      *   ["order"][field name]  index of field named "field name"
      *   The last one is used, if you have a field name, but no index.
      *   Test:  if (isset($result['meta']['myfield'])) { ...
      *
      * - mode is DB_TABLEINFO_ORDERTABLE
      *    the same as above. but additionally
      *   ["ordertable"][table name][field name] index of field
      *      named "field name"
      *
      *      this is, because if you have fields from different
      *      tables with the same field name * they override each
      *      other with DB_TABLEINFO_ORDER
      *
      *      you can combine DB_TABLEINFO_ORDER and
      *      DB_TABLEINFO_ORDERTABLE with DB_TABLEINFO_ORDER |
      *      DB_TABLEINFO_ORDERTABLE * or with DB_TABLEINFO_FULL
      */
     // if $result is a string, then we want information about a
     // table without a resultset
     if (is_string($result)) {
         $id = @fbsql_list_fields($this->dsn['database'], $result, $this->connection);
         if (empty($id)) {
             return $this->fbsqlRaiseError();
         }
     } else {
         // else we want information about a resultset
         $id = $result;
         if (empty($id)) {
             return $this->fbsqlRaiseError();
         }
     }
     $count = @fbsql_num_fields($id);
     // made this IF due to performance (one if is faster than $count if's)
     if (empty($mode)) {
         for ($i = 0; $i < $count; $i++) {
             $res[$i]['table'] = @fbsql_field_table($id, $i);
             $res[$i]['name'] = @fbsql_field_name($id, $i);
             $res[$i]['type'] = @fbsql_field_type($id, $i);
             $res[$i]['len'] = @fbsql_field_len($id, $i);
             $res[$i]['flags'] = @fbsql_field_flags($id, $i);
         }
     } else {
         // full
         $res["num_fields"] = $count;
         for ($i = 0; $i < $count; $i++) {
             $res[$i]['table'] = @fbsql_field_table($id, $i);
             $res[$i]['name'] = @fbsql_field_name($id, $i);
             $res[$i]['type'] = @fbsql_field_type($id, $i);
             $res[$i]['len'] = @fbsql_field_len($id, $i);
             $res[$i]['flags'] = @fbsql_field_flags($id, $i);
             if ($mode & DB_TABLEINFO_ORDER) {
                 $res['order'][$res[$i]['name']] = $i;
             }
             if ($mode & DB_TABLEINFO_ORDERTABLE) {
                 $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
             }
         }
     }
     // free the result only if we were called on a table
     if (is_string($result)) {
         @fbsql_free_result($id);
     }
     return $res;
 }
コード例 #10
0
 public function numFields()
 {
     if (!empty($this->query)) {
         return fbsql_num_fields($this->query);
     } else {
         return 0;
     }
 }
コード例 #11
0
ファイル: fbsql.php プロジェクト: Dulciane/jaws
 /**
  * Count the number of columns returned by the DBMS in a query result.
  *
  * @return mixed integer value with the number of columns, a MDB2 error
  *                       on failure
  * @access public
  */
 function numCols()
 {
     $cols = @fbsql_num_fields($this->result);
     if (null === $cols) {
         if (false === $this->result) {
             return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'resultset has already been freed', __FUNCTION__);
         }
         if (null === $this->result) {
             return count($this->types);
         }
         return $this->db->raiseError(null, null, null, 'Could not get column count', __FUNCTION__);
     }
     return $cols;
 }
コード例 #12
0
ファイル: fbsql.php プロジェクト: ajisantoso/kateglo
 /**
  * Count the number of columns returned by the DBMS in a query result.
  *
  * @return mixed integer value with the number of columns, a MDB2 error
  *                       on failure
  * @access public
  */
 function numCols()
 {
     $cols = @fbsql_num_fields($this->result);
     if (is_null($cols)) {
         if ($this->result === false) {
             return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'numCols: resultset has already been freed');
         } elseif (is_null($this->result)) {
             return count($this->types);
         }
         return $this->db->raiseError();
     }
     return $cols;
 }