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


PHP ADORecordSet::FetchField方法代码示例

本文整理汇总了PHP中ADORecordSet::FetchField方法的典型用法代码示例。如果您正苦于以下问题:PHP ADORecordSet::FetchField方法的具体用法?PHP ADORecordSet::FetchField怎么用?PHP ADORecordSet::FetchField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ADORecordSet的用法示例。


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

示例1: db_fetch_array

/**
 * Retrieve the next row returned from a specific database query
 * @param bool|ADORecordSet $p_result Database Query Record Set to retrieve next result for.
 * @return array Database result
 */
function db_fetch_array(&$p_result)
{
    global $g_db, $g_db_type;
    if ($p_result->EOF) {
        return false;
    }
    # mysql obeys FETCH_MODE_BOTH, hence ->fields works, other drivers do not support this
    if ($g_db_type == 'mysql' || $g_db_type == 'odbc_mssql' || $g_db_type == 'mssqlnative') {
        $t_array = $p_result->fields;
        $p_result->MoveNext();
        return $t_array;
    } else {
        $t_row = $p_result->GetRowAssoc(false);
        static $t_array_result;
        static $t_array_fields;
        if ($t_array_result != $p_result) {
            // new query
            $t_array_result = $p_result;
            $t_array_fields = null;
        } else {
            if ($t_array_fields === null) {
                $p_result->MoveNext();
                return $t_row;
            }
        }
        $t_convert = false;
        $t_fieldcount = $p_result->FieldCount();
        for ($i = 0; $i < $t_fieldcount; $i++) {
            if (isset($t_array_fields[$i])) {
                $t_field = $t_array_fields[$i];
            } else {
                $t_field = $p_result->FetchField($i);
                $t_array_fields[$i] = $t_field;
            }
            switch ($t_field->type) {
                case 'bool':
                    switch ($t_row[$t_field->name]) {
                        case 'f':
                            $t_row[$t_field->name] = false;
                            break;
                        case 't':
                            $t_row[$t_field->name] = true;
                            break;
                    }
                    $t_convert = true;
                    break;
                default:
                    break;
            }
        }
        if ($t_convert == false) {
            $t_array_fields = null;
        }
        $p_result->MoveNext();
        return $t_row;
    }
}
开发者ID:Tarendai,项目名称:spring-website,代码行数:62,代码来源:database_api.php

示例2: recordset_to_assoc

/**
 * Utility function to turn a result set into an associative array of records
 * This method turns a result set into a hash of records (keyed by the first
 * field in the result set)
 *
 * @param  ADORecordSet $rs An ADODB RecordSet object.
 * @return mixed An array of objects, or false if the RecordSet was empty.
 * @throws SQLException
 * @access private
 */
function recordset_to_assoc(ADORecordSet $rs)
{
    if ($rs && $rs->RecordCount() > 0) {
        // First of all, we are going to get the name of the first column
        // to introduce it back after transforming the recordset to assoc array
        // See http://docs.moodle.org/en/XMLDB_Problems, fetch mode problem.
        $firstcolumn = $rs->FetchField(0);
        // Get the whole associative array
        if ($records = $rs->GetAssoc(true)) {
            foreach ($records as $key => $record) {
                $record[$firstcolumn->name] = $key;
                $objects[$key] = (object) $record;
            }
            return $objects;
        } else {
            return false;
        }
    } else {
        return false;
    }
}
开发者ID:vohung96,项目名称:mahara,代码行数:31,代码来源:dml.php


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