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


PHP msql_fetch_array函数代码示例

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


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

示例1: sql_fetch_array

function sql_fetch_array(&$res, $nr = 0)
{
    global $dbtype;
    switch ($dbtype) {
        case "MySQL":
            $row = array();
            $row = mysql_fetch_array($res);
            return $row;
            break;
        case "mSQL":
            $row = array();
            $row = msql_fetch_array($res);
            return $row;
            break;
        case "postgres":
        case "postgres_local":
            if ($res->get_total_rows() > $res->get_fetched_rows()) {
                $row = array();
                $row = pg_fetch_array($res->get_result(), $res->get_fetched_rows());
                $res->increment_fetched_rows();
                return $row;
            } else {
                return false;
            }
            break;
            /*
             * ODBC doesn't have a native _fetch_array(), so we have to
             * use a trick. Beware: this might cause HUGE loads!
             */
        /*
         * ODBC doesn't have a native _fetch_array(), so we have to
         * use a trick. Beware: this might cause HUGE loads!
         */
        case "ODBC":
            $row = array();
            $result = array();
            $result = odbc_fetch_row($res, $nr);
            $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":
            $row = array();
            $result = array();
            $result = odbc_fetch_row($res, $nr);
            $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);
            $row = get_object_vars($orow);
            return $row;
            break;
        case "Sybase":
            $row = sybase_fetch_array($res);
            return $row;
            break;
    }
}
开发者ID:BackupTheBerlios,项目名称:domsmod-svn,代码行数:70,代码来源:sql_layer.php

示例2: fetchInto

 /**
  * Places a row from the result set into the given array
  *
  * Formating of the array and the data therein are configurable.
  * See DB_result::fetchInto() for more information.
  *
  * This method is not meant to be called directly.  Use
  * DB_result::fetchInto() instead.  It can't be declared "protected"
  * because DB_result is a separate object.
  *
  * PHP's mSQL extension did weird things with NULL values prior to PHP
  * 4.3.11 and 5.0.4.  Make sure your version of PHP meets or exceeds
  * those versions.
  *
  * @param resource $result    the query result resource
  * @param array    $arr       the referenced array to put the data in
  * @param int      $fetchmode how the resulting array should be indexed
  * @param int      $rownum    the row number to fetch (0 = first row)
  *
  * @return mixed  DB_OK on success, NULL when the end of a result set is
  *                 reached or on failure
  *
  * @see DB_result::fetchInto()
  */
 function fetchInto($result, &$arr, $fetchmode, $rownum = null)
 {
     if ($rownum !== null) {
         if (!@msql_data_seek($result, $rownum)) {
             return null;
         }
     }
     if ($fetchmode & DB_FETCHMODE_ASSOC) {
         $arr = @msql_fetch_array($result, MSQL_ASSOC);
         if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) {
             $arr = array_change_key_case($arr, CASE_LOWER);
         }
     } else {
         $arr = @msql_fetch_row($result);
     }
     if (!$arr) {
         return null;
     }
     if ($this->options['portability'] & DB_PORTABILITY_RTRIM) {
         $this->_rtrimArrayValues($arr);
     }
     if ($this->options['portability'] & DB_PORTABILITY_NULL_TO_EMPTY) {
         $this->_convertNullArrayValuesToEmpty($arr);
     }
     return DB_OK;
 }
开发者ID:BackupTheBerlios,项目名称:saecommerce,代码行数:50,代码来源:msql.php

示例3: fetchInto

 function fetchInto($result, &$ar, $fetchmode, $rownum = null)
 {
     if ($rownum !== null) {
         if (!@msql_data_seek($result, $rownum)) {
             return null;
         }
     }
     if ($fetchmode & DB_FETCHMODE_ASSOC) {
         $ar = @msql_fetch_array($result, MSQL_ASSOC);
     } else {
         $ar = @msql_fetch_row($result);
     }
     if (!$ar) {
         if ($error = msql_error()) {
             return $this->raiseError($error);
         } else {
             return null;
         }
     }
     return DB_OK;
 }
开发者ID:vojtajina,项目名称:sitellite,代码行数:21,代码来源:msql.php

示例4: convertResource

 protected function convertResource($resource)
 {
     $resourceType = get_resource_type($resource);
     switch ($resourceType) {
         #case 'dbm':
         #case 'dba':
         #case 'dbase':
         #case 'domxml attribute':
         #case 'domxml document':
         #case 'domxml node':
         case 'fbsql result':
             $rows = array();
             $indexType = $this->dbResultIndexType == 'ASSOC' ? FBSQL_ASSOC : FBSQL_NUM;
             while ($row = fbsql_fetch_array($resource, $indexType)) {
                 array_push($rows, $row);
             }
             return $rows;
             #case 'gd': #return base64
         #case 'gd': #return base64
         case 'msql query':
             $rows = array();
             $indexType = $this->dbResultIndexType == 'ASSOC' ? MSQL_ASSOC : MSQL_NUM;
             while ($row = msql_fetch_array($resource, $indexType)) {
                 array_push($rows, $row);
             }
             return $rows;
         case 'mssql result':
             $rows = array();
             $indexType = $this->dbResultIndexType == 'ASSOC' ? MSSQL_ASSOC : MSSQL_NUM;
             while ($row = mssql_fetch_array($resource, $indexType)) {
                 array_push($rows, $row);
             }
             return $rows;
         case 'mysql result':
             $rows = array();
             $indexType = $this->dbResultIndexType == 'ASSOC' ? MYSQL_ASSOC : MYSQL_NUM;
             while ($row = mysql_fetch_array($resource, $indexType)) {
                 array_push($rows, $row);
             }
             return $rows;
         case 'odbc result':
             $rows = array();
             if ($this->dbResultIndexType == 'ASSOC') {
                 while ($row = odbc_fetch_array($resource)) {
                     array_push($rows, $row);
                 }
             } else {
                 while ($row = odbc_fetch_row($resource)) {
                     array_push($rows, $row);
                 }
             }
             return $rows;
             #case 'pdf document':
         #case 'pdf document':
         case 'pgsql result':
             $rows = array();
             $indexType = $this->dbResultIndexType == 'ASSOC' ? PGSQL_ASSOC : PGSQL_NUM;
             while ($row = pg_fetch_array($resource, $indexType)) {
                 array_push($rows, $row);
             }
             return $rows;
         case 'stream':
             return stream_get_contents($resource);
         case 'sybase-db result':
         case 'sybase-ct result':
             $rows = array();
             if ($this->dbResultIndexType == 'ASSOC') {
                 while ($row = sybase_fetch_assoc($resource)) {
                     array_push($rows, $row);
                 }
             } else {
                 while ($row = sybase_fetch_row($resource)) {
                     array_push($rows, $row);
                 }
             }
             return $rows;
             #case 'xml':
         #case 'xml':
         default:
             trigger_error("Unable to return resource type '{$resourceType}'.");
     }
 }
开发者ID:esironal,项目名称:crossui,代码行数:82,代码来源:RPCServer.class.php

示例5: setDbLoop

 /**
  * FUNCTION: setDbLoop [** EXPERIMENTAL **]
  *
  * Function to create a loop from a Db result resource link.
  *
  * @param string $loopname to commit loop. If not set, will use last loopname set using newLoop()
  * @param string $result link to a Db result resource
  * @param string $db_type, type of db that the result resource belongs to.
  * @return boolean true/false
  * @access public
  */
 function setDbLoop($loopname, $result, $db_type = 'MYSQL')
 {
     $db_type = strtoupper($db_type);
     if (!in_array($db_type, $this->allowed_loop_dbs)) {
         vlibTemplateError::raiseError('VT_WARNING_INVALID_LOOP_DB', WARNING, $db_type);
         return false;
     }
     $loop_arr = array();
     switch ($db_type) {
         case 'MYSQL':
             if (get_resource_type($result) != 'mysql result') {
                 vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
                 return false;
             }
             while ($r = mysql_fetch_assoc($result)) {
                 $loop_arr[] = $r;
             }
             break;
         case 'POSTGRESQL':
             if (get_resource_type($result) != 'pgsql result') {
                 vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
                 return false;
             }
             $nr = function_exists('pg_num_rows') ? pg_num_rows($result) : pg_numrows($result);
             for ($i = 0; $i < $nr; $i++) {
                 $loop_arr[] = pg_fetch_array($result, $i, PGSQL_ASSOC);
             }
             break;
         case 'INFORMIX':
             if (!$result) {
                 vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
                 return false;
             }
             while ($r = ifx_fetch_row($result, 'NEXT')) {
                 $loop_arr[] = $r;
             }
             break;
         case 'INTERBASE':
             if (get_resource_type($result) != 'interbase result') {
                 vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
                 return false;
             }
             while ($r = ibase_fetch_row($result)) {
                 $loop_arr[] = $r;
             }
             break;
         case 'INGRES':
             if (!$result) {
                 vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
                 return false;
             }
             while ($r = ingres_fetch_array(INGRES_ASSOC, $result)) {
                 $loop_arr[] = $r;
             }
             break;
         case 'MSSQL':
             if (get_resource_type($result) != 'mssql result') {
                 vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
                 return false;
             }
             while ($r = mssql_fetch_array($result)) {
                 $loop_arr[] = $r;
             }
             break;
         case 'MSQL':
             if (get_resource_type($result) != 'msql result') {
                 vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
                 return false;
             }
             while ($r = msql_fetch_array($result, MSQL_ASSOC)) {
                 $loop_arr[] = $r;
             }
             break;
         case 'OCI8':
             if (get_resource_type($result) != 'oci8 statement') {
                 vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
                 return false;
             }
             while (OCIFetchInto($result, $r, OCI_ASSOC + OCI_RETURN_LOBS)) {
                 $loop_arr[] = $r;
             }
             break;
         case 'ORACLE':
             if (get_resource_type($result) != 'oracle Cursor') {
                 vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type);
                 return false;
             }
             while (ora_fetch_into($result, $r, ORA_FETCHINTO_ASSOC)) {
                 $loop_arr[] = $r;
//.........这里部分代码省略.........
开发者ID:sulaweyo,项目名称:torrentflux-b4rt-php7,代码行数:101,代码来源:vlibTemplate.php

示例6: Send

 function Send()
 {
     $this->error_message();
     $this->getHeader();
     if ($this->smtp) {
         $this->checkSmtp($this->hostSmtp, $this->portSmtp, $this->authenticate, $this->userSmtp, $this->passSmtp);
         $this->socket = $this->connectSmtp($this->hostSmtp, $this->portSmtp, $this->timeoutSmtp);
         switch ($this->smtpServer) {
             case 'esmtp':
                 $this->smtpEhlo($this->socket);
                 break;
             case 'smtp':
                 $this->smtpHelo($this->socket);
                 break;
             case 'test':
                 if ($this->smtpEhlo($this->socket)) {
                     echo nl2br("Connection successful... \r\n Server type: esmtp server \n");
                     return false;
                 } else {
                     $this->smtpQuit($this->socket);
                     $this->disconnectSmtp($this->socket);
                     $this->socket = $this->connectSmtp($this->hostSmtp, $this->portSmtp, $this->timeoutSmtp);
                     if ($this->smtpHelo($this->socket)) {
                         echo nl2br("Connection successful... \r\n Server type: smtp server \n");
                         return false;
                     } else {
                         echo nl2br("Server type: unknown server. \n");
                         return false;
                     }
                 }
         }
         $this->smtpAuth($this->authenticate);
     }
     if ($this->use == "whom") {
         $this->readData($this->setWhom($this->whom));
     } elseif ($this->use == "maillist") {
         $this->readData($this->checkMaillist($this->list));
     } elseif ($this->use == "DB" || $this->use == "all") {
         switch ($this->dbfbasa) {
             case 'mysql':
                 if (!$this->query_result) {
                     return false;
                 }
                 while ($this->tos = mysql_fetch_assoc($this->query_result)) {
                     $this->readData($this->tos);
                 }
                 break;
             case 'pgsql':
                 if (!$this->query_result) {
                     return false;
                 }
                 while ($this->tos = pg_fetch_assoc($this->query_result)) {
                     $this->readData($this->tos);
                 }
                 break;
             case 'ibase':
                 if (!$this->query_result) {
                     return false;
                 }
                 while ($this->tos = ibase_fetch_assoc($this->query_result)) {
                     $this->readData($this->tos);
                 }
                 break;
             case 'msql':
                 if (!$this->query_result) {
                     return false;
                 }
                 while ($this->tos = msql_fetch_array($this->query_result, MSQL_ASSOC)) {
                     $this->readData($this->tos);
                 }
                 break;
             case 'fbsql':
                 if (!$this->query_result) {
                     return false;
                 }
                 while ($this->tos = fbsql_fetch_assoc($this->query_result)) {
                     $this->readData($this->tos);
                 }
                 break;
             case 'sqli':
                 if (!$this->query_result) {
                     return false;
                 }
                 while ($this->tos = sqlite_fetch_array($this->query_result, SQLITE_ASSOC)) {
                     $this->readData($this->tos);
                 }
                 break;
             case 'oci':
                 if (!$this->query_result) {
                     return false;
                 }
                 while ($this->tos = oci_fetch_assoc($this->query_result)) {
                     $this->readData($this->tos);
                 }
                 break;
             case 'sybase':
                 if (!$this->query_result) {
                     return false;
                 }
                 while ($this->tos = sybase_fetch_assoc($this->query_result)) {
//.........这里部分代码省略.........
开发者ID:laiello,项目名称:cartonbank,代码行数:101,代码来源:phpMM_V_23_08_2007.php

示例7: MostPopularNextMatch

function MostPopularNextMatch($dbi, $res)
{
    if ($hits = msql_fetch_array($res)) {
        return $hits;
    } else {
        return 0;
    }
}
开发者ID:BackupTheBerlios,项目名称:oralux,代码行数:8,代码来源:msql.php


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