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


PHP odbc_num_fields函数代码示例

本文整理汇总了PHP中odbc_num_fields函数的典型用法代码示例。如果您正苦于以下问题:PHP odbc_num_fields函数的具体用法?PHP odbc_num_fields怎么用?PHP odbc_num_fields使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了odbc_num_fields函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: odbcAdapter

 /**
  * Constructor method for the adapter.  This constructor implements the setting of the
  * 3 required properties for the object.
  * 
  * The body of this method was provided by Mario Falomir... Thanks.
  * 
  * @param resource $d The datasource resource
  */
 function odbcAdapter($d)
 {
     parent::RecordSetAdapter($d);
     // count number of fields
     $fieldcount = odbc_num_fields($d);
     $ob = "";
     $be = $this->isBigEndian;
     $fc = pack('N', $fieldcount);
     if (odbc_num_rows($d) > 0) {
         $line = odbc_fetch_row($d, 0);
         do {
             // write all of the array elements
             $ob .= "\n" . $fc;
             for ($i = 1; $i <= $fieldcount; $i++) {
                 // write all of the array elements
                 $value = odbc_result($d, $i);
                 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 .= "";
                 }
             }
         } while ($line = odbc_fetch_row($d));
     }
     $this->serializedData = $ob;
     // grab the number of fields
     // loop over all of the fields
     for ($i = 1; $i <= $fieldcount; $i++) {
         // decode each field name ready for encoding when it goes through serialization
         // and save each field name into the array
         $this->columnNames[$i - 1] = $this->_directCharsetHandler->transliterate(odbc_field_name($d, $i));
     }
     $this->numRows = odbc_num_rows($d);
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:67,代码来源:odbcAdapter.php

示例2: num_fields

 function num_fields($res)
 {
     if ($num = odbc_num_fields($res)) {
         return $num;
     } else {
         return false;
     }
 }
开发者ID:ricardoletelier,项目名称:conexion-mysqli-postgresql-desde-php,代码行数:8,代码来源:odbc.php

示例3: fetchFields

 public function fetchFields()
 {
     $fields = array();
     for ($i = 0; $i < odbc_num_fields($this->result); ++$i) {
         $fields[] = odbc_field_name($this->result, $i);
     }
     return $fields;
 }
开发者ID:johsbk,项目名称:penguin,代码行数:8,代码来源:ODBCResultSet.php

示例4: DBGetQuery

function DBGetQuery($result)
{
    // Devuelve la siguiente fila dentro del result-array..
    $arr = array();
    if (odbc_fetch_row($result)) {
        for ($i = 1; $i <= odbc_num_fields($result); $i++) {
            $value = odbc_result($result, $i);
            array_push($arr, $value);
        }
    }
    return $arr;
}
开发者ID:javierlov,项目名称:FuentesWeb,代码行数:12,代码来源:odbc_funcs.php

示例5: listeFourni

function listeFourni()
{
    global $cnx, $liste;
    $cnx = ouvresylob(1);
    //on selectionne tous les champs qui seront utiles
    $sQuery = "SELECT distinct (f.no_frn) as id, f.rais_soc as raison_sociale, a.nom as contact, f.telph as tel, telex as email, \r\n                        CONCAT(a.adr1,a.adr2) as adresse, CONCAT(a.cd_post,a.ville) as ville\r\n                FROM (informix.bas_frn f \r\n                INNER JOIN informix.bas_adrfrn a ON a.no_frn = f.no_frn) \r\n                LEFT JOIN informix.zz_materiel m ON m.frn_materiel = f.no_frn\r\n                WHERE f.no_frn is not null\r\n                AND a.no_adr = 1\r\n                ORDER BY f.rais_soc asc, a.nom asc";
    //echo $sQuery;
    $res = odbc_exec($cnx, $sQuery);
    $i = 0;
    while (odbc_fetch_row($res)) {
        for ($j = 1; $j <= odbc_num_fields($res); $j++) {
            $liste[$i][odbc_field_name($res, $j)] = odbc_result($res, $j);
        }
        $i++;
    }
    //odbc_close($cnx);
    return $liste;
}
开发者ID:enoram,项目名称:maintenance,代码行数:18,代码来源:fournisseur.class.php

示例6: odbcAdapter

 /**
  * Constructor method for the adapter.  This constructor implements the setting of the
  * 3 required properties for the object.
  * 
  * The body of this method was provided by Mario Falomir... Thanks.
  * 
  * @param resource $d The datasource resource
  */
 function odbcAdapter($d)
 {
     parent::RecordSetAdapter($d);
     // count number of fields
     $fieldcount = odbc_num_fields($d);
     // grab the number of fields
     // loop over all of the fields
     for ($i = 0; $i < $fieldcount; $i++) {
         // decode each field name ready for encoding when it goes through serialization
         // and save each field name into the array
         $this->columns[] = odbc_field_name($d, $i + 1);
     }
     if (odbc_num_rows($d) > 0) {
         $line = odbc_fetch_row($d, 0);
         do {
             $this->rows[] = $line;
         } while ($line = odbc_fetch_row($d));
     }
 }
开发者ID:nimigeanu,项目名称:hollow,代码行数:27,代码来源:odbcAdapter.php

示例7: db_colnum

 function db_colnum($oStmt)
 {
     return odbc_num_fields($oStmt);
 }
开发者ID:brustj,项目名称:tracmor,代码行数:4,代码来源:db_odbc.php

示例8: RetrieveODBCData

 function RetrieveODBCData($action)
 {
     $availableActions = array('-delete', '-edit', '-find', '-findall', '-new', '-sqlquery');
     if (!in_array(strtolower($action), $availableActions)) {
         // first off, toss out any requests for actions NOT supported under ODBC
         return new FX_Error("The action requested ({$action}) is not supported under ODBC via FX.php.");
     }
     $odbc_res = odbc_connect($this->database, $this->DBUser, $this->DBPassword);
     // although username and password are optional for this function, FX.php expects them to be set
     if ($odbc_res == false) {
         return new FX_Error('Unable to connect to ODBC data source.');
     }
     switch ($action) {
         case '-delete':
         case '-edit':
         case '-find':
         case '-findall':
         case '-new':
             $this->dataQuery = $this->BuildSQLQuery($action);
             if (FX::isError($this->dataQuery)) {
                 return $this->dataQuery;
             }
         case '-sqlquery':
             // note that there is no preceding break, as we don't want to build a query
             $odbc_result = odbc_exec($odbc_res, $this->dataQuery);
             if (!$odbc_result) {
                 $tempErrorText = odbc_errormsg($odbc_res);
                 odbc_close($odbc_res);
                 return new FX_Error("Unsuccessful query: {$this->dataQuery} ({$tempErrorText})");
             }
             $this->foundCount = odbc_num_rows($odbc_result);
             $fieldCount = odbc_num_fields($odbc_result);
             if ($theResult < 0) {
                 $tempErrorText = odbc_errormsg($odbc_res);
                 odbc_close($odbc_res);
                 return new FX_Error("Unable to access field count for current ODBC query.  ({$tempErrorText})");
             }
             $odbc_columns = odbc_columns($odbc_res);
             if (!$odbc_columns) {
                 $tempErrorText = odbc_errormsg($odbc_res);
                 odbc_close($odbc_res);
                 return new FX_Error("Unable to retrieve column data via ODBC.  ({$tempErrorText})");
             }
             while (odbc_fetch_row($odbc_columns)) {
                 $fieldNumber = odbc_result($odbc_columns, 'ORDINAL_POSITION');
                 $this->fieldInfo[$fieldNumber]['name'] = odbc_result($odbc_columns, 'COLUMN_NAME');
                 $this->fieldInfo[$fieldNumber]['type'] = odbc_result($odbc_columns, 'TYPE_NAME');
                 $this->fieldInfo[$fieldNumber]['emptyok'] = odbc_result($odbc_columns, 'IS_NULLABLE');
                 $this->fieldInfo[$fieldNumber]['maxrepeat'] = 1;
                 $this->fieldInfo[$fieldNumber]['extra'] = 'COLUMN_SIZE:' . odbc_result($odbc_columns, 'COLUMN_SIZE') . '|BUFFER_LENGTH:' . odbc_result($odbc_columns, 'BUFFER_LENGTH') . '|NUM_PREC_RADIX:' . odbc_result($odbc_columns, 'NUM_PREC_RADIX');
             }
             while (odbc_fetch_row($odbc_result)) {
                 $tempRow = array();
                 for ($i = 1; $i <= $fieldCount; ++$i) {
                     $theResult = odbc_result($odbc_result, $i);
                     if (!$this->useInnerArray) {
                         $tempRow[$this->fieldInfo[$i]['name']] = $theResult;
                     } else {
                         $tempRow[$this->fieldInfo[$i]['name']] = array($theResult);
                     }
                     if ($this->fieldInfo[$i]['name'] == $this->primaryKeyField) {
                         $currentKey = $theResult;
                     }
                 }
                 if ($this->genericKeys || $this->primaryKeyField == '') {
                     $this->currentData[] = $tempRow;
                 } else {
                     $this->currentData[$currentKey] = $tempRow;
                 }
             }
             break;
         default:
             return new FX_Error("The action requested ({$action}) is not supported by FileMaker under ODBC via FX.php.");
             break;
     }
     $this->fxError = 0;
     return true;
 }
开发者ID:nojimage,项目名称:FileMaker-Todo-App,代码行数:78,代码来源:FX.php

示例9: _initrs

 function _initrs()
 {
     global $ADODB_COUNTRECS;
     $this->_numOfRows = $ADODB_COUNTRECS ? @odbc_num_rows($this->_queryID) : -1;
     $this->_numOfFields = @odbc_num_fields($this->_queryID);
     // some silly drivers such as db2 as/400 and intersystems cache return _numOfRows = 0
     if ($this->_numOfRows == 0) {
         $this->_numOfRows = -1;
     }
     //$this->useFetchArray = $this->connection->useFetchArray;
     $this->_has_stupid_odbc_fetch_api_change = ADODB_PHPVER >= 0x4200;
 }
开发者ID:joeymetal,项目名称:v1,代码行数:12,代码来源:adodb-odbc.inc.php

示例10: sql_query

 function sql_query($query = "", $transaction = FALSE)
 {
     if ($query != "") {
         $this->num_queries++;
         if ($transaction == BEGIN_TRANSACTION && !$this->in_transaction) {
             if (!odbc_autocommit($this->db_connect_id, false)) {
                 return false;
             }
             $this->in_transaction = TRUE;
         }
         if (preg_match("/^SELECT(.*?)(LIMIT ([0-9]+)[, ]*([0-9]+)*)?\$/s", $query, $limits)) {
             $query = $limits[1];
             if (!empty($limits[2])) {
                 $row_offset = $limits[4] ? $limits[3] : "";
                 $num_rows = $limits[4] ? $limits[4] : $limits[3];
                 $query = "TOP " . ($row_offset + $num_rows) . $query;
             }
             $this->result = odbc_exec($this->db_connect_id, "SELECT {$query}");
             if ($this->result) {
                 if (empty($this->field_names[$this->result])) {
                     for ($i = 1; $i < odbc_num_fields($this->result) + 1; $i++) {
                         $this->field_names[$this->result][] = odbc_field_name($this->result, $i);
                         $this->field_types[$this->result][] = odbc_field_type($this->result, $i);
                     }
                 }
                 $this->current_row[$this->result] = 0;
                 $this->result_rowset[$this->result] = array();
                 $row_outer = isset($row_offset) ? $row_offset + 1 : 1;
                 $row_outer_max = isset($num_rows) ? $row_offset + $num_rows + 1 : 1000000000.0;
                 $row_inner = 0;
                 while (odbc_fetch_row($this->result, $row_outer) && $row_outer < $row_outer_max) {
                     for ($j = 0; $j < count($this->field_names[$this->result]); $j++) {
                         $this->result_rowset[$this->result][$row_inner][$this->field_names[$this->result][$j]] = stripslashes(odbc_result($this->result, $j + 1));
                     }
                     $row_outer++;
                     $row_inner++;
                 }
                 $this->num_rows[$this->result] = count($this->result_rowset[$this->result]);
             }
         } else {
             if (eregi("^INSERT ", $query)) {
                 $this->result = odbc_exec($this->db_connect_id, $query);
                 if ($this->result) {
                     $result_id = odbc_exec($this->db_connect_id, "SELECT @@IDENTITY");
                     if ($result_id) {
                         if (odbc_fetch_row($result_id)) {
                             $this->next_id[$this->db_connect_id] = odbc_result($result_id, 1);
                             $this->affected_rows[$this->db_connect_id] = odbc_num_rows($this->result);
                         }
                     }
                 }
             } else {
                 $this->result = odbc_exec($this->db_connect_id, $query);
                 if ($this->result) {
                     $this->affected_rows[$this->db_connect_id] = odbc_num_rows($this->result);
                 }
             }
         }
         if (!$this->result) {
             if ($this->in_transaction) {
                 odbc_rollback($this->db_connect_id);
                 odbc_autocommit($this->db_connect_id, true);
                 $this->in_transaction = FALSE;
             }
             return false;
         }
         if ($transaction == END_TRANSACTION && $this->in_transaction) {
             $this->in_transaction = FALSE;
             if (!odbc_commit($this->db_connect_id)) {
                 odbc_rollback($this->db_connect_id);
                 odbc_autocommit($this->db_connect_id, true);
                 return false;
             }
             odbc_autocommit($this->db_connect_id, true);
         }
         odbc_free_result($this->result);
         return $this->result;
     } else {
         if ($transaction == END_TRANSACTION && $this->in_transaction) {
             $this->in_transaction = FALSE;
             if (!@odbc_commit($this->db_connect_id)) {
                 odbc_rollback($this->db_connect_id);
                 odbc_autocommit($this->db_connect_id, true);
                 return false;
             }
             odbc_autocommit($this->db_connect_id, true);
         }
         return true;
     }
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:90,代码来源:mssql-odbc.php

示例11: msaccess_data

 function msaccess_data()
 {
     if (($this->error = $this->checkCredentials()) != "") {
         return $this->error;
     }
     if (!($con = odbc_connect("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . $this->database_name, $this->username, $this->password))) {
         return odbc_errormsg($conn);
     }
     if (!($res = odbc_exec($con, $this->query))) {
         return "Query Failed";
     }
     $i = 0;
     $this->data = array();
     $col = odbc_num_fields($res);
     for ($f = 1; $f <= $col; $f++) {
         $key_arr[] = odbc_field_name($res, $f);
     }
     while ($thisrow = odbc_fetch_array($res)) {
         $this->data[$i] = array();
         foreach ($key_arr as $key) {
             $this->data[$i][$key] = $thisrow[$key];
         }
         $i++;
     }
     odbc_close($con);
 }
开发者ID:BoulderOWASP,项目名称:SnowFROC_CTF_2013_Exercises,代码行数:26,代码来源:phpchart.class.php

示例12: _initrs

 function _initrs()
 {
     $this->_numOfRows = @odbc_num_rows($this->_queryID);
     $this->_numOfFields = @odbc_num_fields($this->_queryID);
 }
开发者ID:qoire,项目名称:portal,代码行数:5,代码来源:adodb-odbc.inc.php

示例13: sql_fetch_object

function sql_fetch_object(&$res, $nr = 0)
{
    global $dbtype;
    switch ($dbtype) {
        case "MySQL":
            $row = mysql_fetch_object($res);
            if ($row) {
                return $row;
            } else {
                return false;
            }
            break;
        case "mSQL":
            $row = msql_fetch_object($res);
            if ($row) {
                return $row;
            } else {
                return false;
            }
            break;
        case "postgres":
        case "postgres_local":
            if ($res->get_total_rows() > $res->get_fetched_rows()) {
                $row = pg_fetch_object($res->get_result(), $res->get_fetched_rows());
                $res->increment_fetched_rows();
                if ($row) {
                    return $row;
                } else {
                    return false;
                }
            } else {
                return false;
            }
            break;
        case "ODBC":
            $result = odbc_fetch_row($res, $nr);
            if (!$result) {
                return false;
            }
            $nf = odbc_num_fields($res);
            /* Field numbering starts at 1 */
            for ($count = 1; $count < $nf + 1; $count++) {
                $field_name = odbc_field_name($res, $count);
                $field_value = odbc_result($res, $field_name);
                $row->{$field_name} = $field_value;
            }
            return $row;
            break;
        case "ODBC_Adabas":
            $result = odbc_fetch_row($res, $nr);
            if (!$result) {
                return false;
            }
            $nf = count($result) + 2;
            /* Field numbering starts at 1 */
            for ($count = 1; $count < $nf; $count++) {
                $field_name = odbc_field_name($res, $count);
                $field_value = odbc_result($res, $field_name);
                $row->{$field_name} = $field_value;
            }
            return $row;
            break;
        case "Interbase":
            $orow = ibase_fetch_object($res);
            if ($orow) {
                $arow = get_object_vars($orow);
                while (list($name, $key) = each($arow)) {
                    $name = strtolower($name);
                    $row->{$name} = $key;
                }
                return $row;
            } else {
                return false;
            }
            break;
        case "Sybase":
            $row = sybase_fetch_object($res);
            return $row;
            break;
    }
}
开发者ID:BackupTheBerlios,项目名称:domsmod-svn,代码行数:81,代码来源:sql_layer.php

示例14: sql_query

 function sql_query($query = "", $transaction = FALSE)
 {
     //
     // Remove any pre-existing queries
     //
     unset($this->query_result);
     unset($this->row);
     if ($query != "") {
         $this->num_queries++;
         if (!eregi("^INSERT ", $query)) {
             if (eregi("LIMIT", $query)) {
                 preg_match("/^(.*)LIMIT ([0-9]+)[, ]*([0-9]+)*/s", $query, $limits);
                 $query = $limits[1];
                 if ($limits[3]) {
                     $row_offset = $limits[2];
                     $num_rows = $limits[3];
                 } else {
                     $row_offset = 0;
                     $num_rows = $limits[2];
                 }
                 $query .= " FETCH FIRST " . ($row_offset + $num_rows) . " ROWS ONLY OPTIMIZE FOR " . ($row_offset + $num_rows) . " ROWS";
                 $this->query_result = odbc_exec($this->db_connect_id, $query);
                 $query_limit_offset = $row_offset;
                 $this->result_numrows[$this->query_result] = $num_rows;
             } else {
                 $this->query_result = odbc_exec($this->db_connect_id, $query);
                 $row_offset = 0;
                 $this->result_numrows[$this->query_result] = 5000000.0;
             }
             $result_id = $this->query_result;
             if ($this->query_result && eregi("^SELECT", $query)) {
                 for ($i = 1; $i < odbc_num_fields($result_id) + 1; $i++) {
                     $this->result_field_names[$result_id][] = odbc_field_name($result_id, $i);
                 }
                 $i = $row_offset + 1;
                 $k = 0;
                 while (odbc_fetch_row($result_id, $i) && $k < $this->result_numrows[$result_id]) {
                     for ($j = 1; $j < count($this->result_field_names[$result_id]) + 1; $j++) {
                         $this->result_rowset[$result_id][$k][$this->result_field_names[$result_id][$j - 1]] = odbc_result($result_id, $j);
                     }
                     $i++;
                     $k++;
                 }
                 $this->result_numrows[$result_id] = $k;
                 $this->row_index[$result_id] = 0;
             } else {
                 $this->result_numrows[$result_id] = @odbc_num_rows($result_id);
                 $this->row_index[$result_id] = 0;
             }
         } else {
             if (eregi("^(INSERT|UPDATE) ", $query)) {
                 $query = preg_replace("/\\\\'/s", "''", $query);
             }
             $this->query_result = odbc_exec($this->db_connect_id, $query);
             if ($this->query_result) {
                 $sql_id = "VALUES(IDENTITY_VAL_LOCAL())";
                 $id_result = odbc_exec($this->db_connect_id, $sql_id);
                 if ($id_result) {
                     $row_result = odbc_fetch_row($id_result);
                     if ($row_result) {
                         $this->next_id[$this->query_result] = odbc_result($id_result, 1);
                     }
                 }
             }
             odbc_commit($this->db_connect_id);
             $this->query_limit_offset[$this->query_result] = 0;
             $this->result_numrows[$this->query_result] = 0;
         }
         return $this->query_result;
     } else {
         return false;
     }
 }
开发者ID:nmpetkov,项目名称:ZphpBB2,代码行数:73,代码来源:db2.php

示例15: mysql_free_result

             $data[] = $row;
         }
     }
     mysql_free_result($result);
     mysql_close($connection);
     break;
 case 'ORACLE':
     $connect = odbc_connect($servername, $username, $password);
     $result = odbc_exec($connect, $sql);
     # return error if query failed
     if (!$result) {
         print json_encode(array('error' => array('message' => odbc_errormsg($connect), 'code' => odbc_error($connect))));
         exit;
     } else {
         #odbc returns results as strings, so get datatype fields here
         for ($x = 1; $x <= odbc_num_fields($result); $x++) {
             $types[] = odbc_field_type($result, $x);
         }
         while ($row = odbc_fetch_array($result)) {
             $x = 0;
             #convert each string to its actual datatype, so easily usable in javascript
             foreach ($row as $key => $value) {
                 switch ($types[$x]) {
                     case 'NUMBER':
                         $row[$key] = $value + 0;
                         break;
                     default:
                         break;
                 }
                 $x++;
             }
开发者ID:BryanJacobHunter,项目名称:tcmCoilApp,代码行数:31,代码来源:json_db_lib.php


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