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


PHP mssql_num_fields函数代码示例

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


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

示例1: xcopy

function xcopy($mssql, $mysql, $db, $table, $sql)
{
    $start = microtime(true);
    mysqli_select_db($mysql, $db);
    mssql_select_db($db, $mssql);
    $result = mssql_query($sql, $mssql, 20000);
    if ($result === false) {
        die("Error creating sync data\n");
    }
    $s = 0;
    $r = mssql_num_rows($result);
    $name_count = mssql_num_fields($result);
    $name_list = "";
    $update_list = "";
    $value_list = "";
    $sql = "";
    $radix = 0;
    for ($i = 0; $i < $name_count; $i++) {
        $x = strtolower(mssql_field_name($result, $i));
        $name_list .= "{$x},";
        if ($x != "dex_row_id") {
            $update_list .= "{$x} = values({$x}),";
        }
    }
    $name_list = rtrim($name_list, ",");
    $update_list = rtrim($update_list, ",");
    do {
        while ($row = mssql_fetch_row($result)) {
            for ($i = 0; $i < $name_count; $i++) {
                $value_list .= "'" . str_replace("'", "''", trim($row[$i])) . "',";
            }
            $value_list = rtrim($value_list, ",");
            $radix++;
            $sql .= "\n({$value_list}),";
            $value_list = "";
            if ($radix > 2000) {
                $sql = trim($sql, ",");
                $sql = "insert into {$table} ({$name_list}) values {$sql} on duplicate key update {$update_list};";
                $rset = mysqli_query($mysql, $sql);
                if ($rset === false) {
                    die("Error inserting mysql data. \n" . mysqli_error($mysql) . "\n\n{$sql}\n\n");
                }
                $radix = 0;
                $sql = "";
            }
            $s++;
        }
    } while (mssql_fetch_batch($result));
    if ($sql != "") {
        $sql = trim($sql, ",");
        $sql = "insert into {$table} ({$name_list}) values {$sql} on duplicate key update {$update_list};";
        $rset = mysqli_query($mysql, $sql);
        if ($rset === false) {
            die("Error inserting mysql data. \n" . mysqli_error($mysql) . "\n\n{$sql}\n\n");
        }
    }
    $end = microtime(true);
    $total = $end - $start;
    echo "imported {$db}.{$table} [ {$s} ] records in {$total} sec.\n";
}
开发者ID:afindlator,项目名称:gpApi,代码行数:60,代码来源:xcopy.php

示例2: columnCount

 public function columnCount()
 {
     if ($this->_result) {
         return mssql_num_fields($this->_result);
     }
     return 0;
 }
开发者ID:PHPcomaptibility,项目名称:PHPPDO,代码行数:7,代码来源:mssql_statement.php

示例3: table_copy

function table_copy($xsql, $table)
{
    global $old_gp;
    global $new_gp;
    $name = "";
    $names = "";
    $feilds = "";
    $sql = "truncate table {$table};";
    $inc = 0;
    $rset = mssql_query($xsql, $old_gp);
    while ($line = mssql_fetch_assoc($rset)) {
        $names = "";
        $feilds = "";
        for ($inc = 0; $inc < mssql_num_fields($rset); $inc++) {
            $name = trim(mssql_field_name($rset, $inc));
            if ($names == "") {
                $names = $name;
            } else {
                $names .= ", {$name}";
            }
            if ($feilds == "") {
                $feilds = "'" . str_replace("'", "''", trim($line[$name])) . "'";
            } else {
                $feilds .= ", '" . str_replace("'", "''", trim($line[$name])) . "'";
            }
        }
        $sql .= "insert into {$table} ({$names}) values ({$feilds});\n";
        echo "{$sql}";
        mssql_query($sql, $new_gp);
        $sql = "";
    }
    //echo $sql;
}
开发者ID:afindlator,项目名称:gpApi,代码行数:33,代码来源:copy_gp.php

示例4: get_web_log

 public function get_web_log()
 {
     //select the database
     mssql_select_db($this->dbname, $this->dbcon);
     //SQL Select statement
     $xml = new XMLHandler(XML_DIR . "web_request_spk.xml");
     $sql_from_xml = $xml->getNode("web_log");
     $sqlselect = str_replace("FILTER_BY_PROGRAM", "", $sql_from_xml);
     //Run the SQL query
     $result = mssql_query($sqlselect);
     $numfields = mssql_num_fields($result);
     $string_result = "";
     while ($row = mssql_fetch_row($result)) {
         $string_result .= "<tr>";
         for ($i = 0; $i < $numfields; $i++) {
             if (mssql_field_name($result, $i) == "IP_ADDRESS") {
                 $ip = explode(":", $row[$i]);
                 $string_result .= "<td>" . $ip[0] . "</td>";
                 $string_result .= "<td>" . $ip[1] . "</td>";
             } else {
                 $string_result .= "<td>" . $row[$i] . "</td>";
             }
         }
         $string_result .= "</tr>";
     }
     return $string_result;
 }
开发者ID:edosatriani,项目名称:greensys,代码行数:27,代码来源:web_log_Model.php

示例5: select_to_table

function select_to_table($query)
{
    $results = mssql_query($query) or die("<li>errorno=" . mysql_errno() . "<li>error=" . mysql_error() . "<li>query=" . $query);
    $number_cols = mssql_num_fields($results);
    //display query
    echo "<b>query: {$query}</b>";
    //layout table header
    echo "<table border = 1>\n";
    echo "<tr align left>\n";
    for ($i = 0; $i < $number_cols; $i++) {
        echo "<th>" . mssql_field_name($results, $i) . "</th>\n";
    }
    echo "</tr>\n";
    //end table header
    //layout table body
    while ($row = mssql_fetch_row($results)) {
        echo "<tr align left>\n";
        for ($i = 0; $i < $number_cols; $i++) {
            echo "<td>";
            if (!isset($row[$i])) {
                echo "NULL";
            } else {
                echo $row[$i];
            }
            echo "</td>\n";
        }
        echo "</tr>\n";
    }
    echo "</table>\n";
}
开发者ID:blynch-newpi,项目名称:IS4C,代码行数:30,代码来源:chrisFunct.php

示例6: mssqlAdapter

 /**
  * 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 mssqlAdapter($d)
 {
     parent::RecordSetAdapter($d);
     $fieldcount = mssql_num_fields($d);
     // grab the number of fields
     $ob = "";
     $be = $this->isBigEndian;
     $fc = pack('N', $fieldcount);
     if (mssql_num_rows($d) > 0) {
         mssql_data_seek($d, 0);
         while ($line = mssql_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;
     for ($i = 0; $i < $fieldcount; $i++) {
         // loop over all of the fields
         $this->columnNames[] = $this->_directCharsetHandler->transliterate(mssql_field_name($d, $i));
     }
     $this->numRows = mssql_num_rows($d);
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:61,代码来源:mssqlAdapter.php

示例7: _performGetBlobFieldNames

 function _performGetBlobFieldNames($result)
 {
     $blobFields = array();
     for ($i = mssql_num_fields($result) - 1; $i >= 0; $i--) {
         $type = mssql_field_type($result, $i);
         if (strpos($type, "BLOB") !== false) {
             $blobFields[] = mssql_field_name($result, $i);
         }
     }
     return $blobFields;
 }
开发者ID:Ambalus,项目名称:DbSimple,代码行数:11,代码来源:Mssql.php

示例8: __construct

 /**
  * Constructor
  *
  * @param   resource handle
  */
 public function __construct($result, TimeZone $tz = NULL)
 {
     $fields = array();
     if (is_resource($result)) {
         for ($i = 0, $num = mssql_num_fields($result); $i < $num; $i++) {
             $field = mssql_fetch_field($result, $i);
             $fields[$field->name] = $field->type;
         }
     }
     parent::__construct($result, $fields, $tz);
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:16,代码来源:MsSQLResultSet.class.php

示例9: funDevuelveArregloRecordsetMS

function funDevuelveArregloRecordsetMS($parERecordset, &$parSArray)
{
    // Obtiene las logitudes del arreglo
    $nrMS = mssql_num_rows($parERecordset);
    $nfMS = mssql_num_fields($parERecordset);
    for ($varI = 0; $varI < $nrMS; $varI++) {
        $results = mssql_fetch_array($parERecordset);
        for ($varJ = 0; $varJ < $nfMS; $varJ++) {
            $varFielName = mssql_field_name($parERecordset, $varJ);
            $parSArray[$varFielName][$varI] = $results[$varFielName];
        }
    }
    // Retorna el numero de registros (filas del arreglo(
    return $nrMS;
}
开发者ID:boris1690,项目名称:arcimed,代码行数:15,代码来源:database_mssql.php

示例10: mssqlAdapter

 /**
  * 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 mssqlAdapter($d)
 {
     parent::RecordSetAdapter($d);
     $fieldcount = mssql_num_fields($d);
     // grab the number of fields
     for ($i = 0; $i < $fieldcount; $i++) {
         // loop over all of the fields
         $this->columnNames[] = mssql_field_name($d, $i);
     }
     if (mssql_num_rows($d) > 0) {
         mssql_data_seek($d, 0);
         while ($line = mssql_fetch_row($d)) {
             $this->rows[] = $line;
         }
     }
 }
开发者ID:BGCX067,项目名称:ezplanner-svn-to-git,代码行数:22,代码来源:mssqlAdapter.php

示例11: read

 public function read($sql)
 {
     $data = [];
     $result = mssql_query($sql, $this->gp, 10000);
     if ($result === false) {
         throw new \Exception("Error creating sync data");
     }
     $name_count = mssql_num_fields($result);
     do {
         $x = [];
         while ($row = mssql_fetch_assoc($result)) {
             foreach ($row as $key => $value) {
                 $x[strtolower($key)] = trim($value);
             }
             $data[] = $x;
         }
     } while (mssql_fetch_batch($result));
     return $data;
 }
开发者ID:afindlator,项目名称:gpApi,代码行数:19,代码来源:GP.php

示例12: get_unit_rfs

 public function get_unit_rfs()
 {
     //select the database
     mssql_select_db($this->dbname, $this->dbcon);
     //SQL Select statement
     $xml = new XMLHandler(XML_DIR . "web_request_spk.xml");
     $sql_from_xml = $xml->getNode("rfs");
     $sqlselect = str_replace("FILTER_BY_PROGRAM", "", $sql_from_xml);
     //Run the SQL query
     $result = mssql_query($sqlselect);
     $numfields = mssql_num_fields($result);
     $string_result = "";
     while ($row = mssql_fetch_row($result)) {
         $string_result .= "<tr>";
         for ($i = 0; $i < $numfields; $i++) {
             $string_result .= "<td>" . $row[$i] . "</td>";
         }
         $string_result .= "</tr>";
     }
     return $string_result;
 }
开发者ID:edosatriani,项目名称:greensys,代码行数:21,代码来源:stock_Model.php

示例13: dashboard_summary

 public function dashboard_summary()
 {
     //select the database
     mssql_select_db($this->dbname, $this->dbcon);
     //SQL Select statement
     $xml = new XMLHandler(XML_DIR . "web_request_spk.xml");
     $sql_from_xml = $xml->getNode("dashboard_summary");
     $sqlselect = str_replace("FILTER_BY_PROGRAM", "'" . $_SESSION["user-ws"] . "'", $sql_from_xml);
     //Run the SQL query
     $result = mssql_query($sqlselect);
     $numfields = mssql_num_fields($result);
     $jsonString = "{\"dt_objectTable\": {\"dt_fieldsCollection\":[@fieldsCollection@],\"tableName\":\"dashboard_summary\",\"modify_status\":\"ORI\"}}";
     $fieldsCollection = "";
     while ($row = mssql_fetch_row($result)) {
         if ($fieldsCollection != "") {
             $fieldsCollection .= ",";
         }
         $fieldsCollection .= "{\"fieldName\":\"" . $row[0] . "\",\"fieldValue\":\"" . $row[1] . "\"}";
     }
     $jsonString = str_replace("@fieldsCollection@", $fieldsCollection, $jsonString);
     return $jsonString;
 }
开发者ID:edosatriani,项目名称:greensys,代码行数:22,代码来源:dashboard_Model.php

示例14: __get

 /**
  * Dynamic Get Function Override
  *
  * @param $name
  *   A string containing the name of the property to get.
  * @return
  *   Value of the property.
  */
 public function __get($propertyName)
 {
     //        global $firePHP;
     if ($propertyName == 'columns') {
         if (!isset($this->_columns)) {
             //---- Get Columns
             $this->_columns = new anvilCollection();
             $i = 0;
             //                $sql = 'SHOW COLUMNS FROM ';
             while ($i < mssql_num_fields($this->result)) {
                 $meta = mssql_fetch_field($this->result, $i);
                 if ($meta) {
                     //                       $firePHP->_log($meta);
                     $newColumn = new anvilData_mssql_Column($meta->name, $meta->type);
                     $this->_columns->add($newColumn);
                 }
                 $i++;
             }
         }
         return $this->_columns;
     } else {
         return parent::__get($propertyName);
     }
 }
开发者ID:nslevkoff,项目名称:phpAnvil2,代码行数:32,代码来源:anvilData_mssql_Recordset.class.php

示例15: sql_num_fields

 function sql_num_fields($sqltype, $result)
 {
     if ($sqltype == 'mysql') {
         if (class_exists('mysqli_result')) {
             return $result->field_count;
         } elseif (function_exists('mysql_num_fields')) {
             return mysql_num_fields($result);
         }
     } elseif ($sqltype == 'mssql') {
         if (function_exists('sqlsrv_num_fields')) {
             return sqlsrv_num_fields($result);
         } elseif (function_exists('mssql_num_fields')) {
             return mssql_num_fields($result);
         }
     } elseif ($sqltype == 'pgsql') {
         return pg_num_fields($result);
     } elseif ($sqltype == 'oracle') {
         return oci_num_fields($result);
     } elseif ($sqltype == 'sqlite3') {
         return $result->numColumns();
     } elseif ($sqltype == 'sqlite') {
         return sqlite_num_fields($result);
     } elseif ($sqltype == 'odbc') {
         return odbc_num_fields($result);
     } elseif ($sqltype == 'pdo') {
         return $result->columnCount();
     }
 }
开发者ID:retanoj,项目名称:webshellSample,代码行数:28,代码来源:7394316867fbf40088309b5150e77721.php


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