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


PHP mssql_field_name函数代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: _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

示例7: 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

示例8: 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

示例9: querY

function querY($type, $host, $user, $pass, $db = '', $query)
{
    $res = '';
    switch ($type) {
        case 'MySQL':
            if (!function_exists('mysql_connect')) {
                return 0;
            }
            $link = mysql_connect($host, $user, $pass);
            if ($link) {
                if (!empty($db)) {
                    mysql_select_db($db, $link);
                }
                $result = mysql_query($query, $link);
                while ($data = mysql_fetch_row($result)) {
                    $res .= implode('|-|-|-|-|-|', $data) . '|+|+|+|+|+|';
                }
                $res .= '[+][+][+]';
                for ($i = 0; $i < mysql_num_fields($result); $i++) {
                    $res .= mysql_field_name($result, $i) . '[-][-][-]';
                }
                mysql_close($link);
                return $res;
            }
            break;
        case 'MSSQL':
            if (!function_exists('mssql_connect')) {
                return 0;
            }
            $link = mssql_connect($host, $user, $pass);
            if ($link) {
                if (!empty($db)) {
                    mssql_select_db($db, $link);
                }
                $result = mssql_query($query, $link);
                while ($data = mssql_fetch_row($result)) {
                    $res .= implode('|-|-|-|-|-|', $data) . '|+|+|+|+|+|';
                }
                $res .= '[+][+][+]';
                for ($i = 0; $i < mssql_num_fields($result); $i++) {
                    $res .= mssql_field_name($result, $i) . '[-][-][-]';
                }
                mssql_close($link);
                return $res;
            }
            break;
        case 'Oracle':
            if (!function_exists('ocilogon')) {
                return 0;
            }
            $link = ocilogon($user, $pass, $db);
            if ($link) {
                $stm = ociparse($link, $query);
                ociexecute($stm, OCI_DEFAULT);
                while ($data = ocifetchinto($stm, $data, OCI_ASSOC + OCI_RETURN_NULLS)) {
                    $res .= implode('|-|-|-|-|-|', $data) . '|+|+|+|+|+|';
                }
                $res .= '[+][+][+]';
                for ($i = 0; $i < oci_num_fields($stm); $i++) {
                    $res .= oci_field_name($stm, $i) . '[-][-][-]';
                }
                return $res;
            }
            break;
        case 'PostgreSQL':
            if (!function_exists('pg_connect')) {
                return 0;
            }
            $link = pg_connect("host={$host} dbname={$db} user={$user} password={$pass}");
            if ($link) {
                $result = pg_query($link, $query);
                while ($data = pg_fetch_row($result)) {
                    $res .= implode('|-|-|-|-|-|', $data) . '|+|+|+|+|+|';
                }
                $res .= '[+][+][+]';
                for ($i = 0; $i < pg_num_fields($result); $i++) {
                    $res .= pg_field_name($result, $i) . '[-][-][-]';
                }
                pg_close($link);
                return $res;
            }
            break;
    }
    return 0;
}
开发者ID:retanoj,项目名称:webshellSample,代码行数:85,代码来源:a824680ae0452cb5a0bebc0e8bf858f4.php

示例10: getColnames

 public function getColnames($result)
 {
     if (!is_resource($result)) {
         throw new DbControlException("Ilegal parameter result. Must be valid result resource.");
     }
     if (!($numFields = @mssql_num_fields($result))) {
         throw new DbControlException("No Column in result.");
     }
     for ($i = 0; $i < $numFields; $i++) {
         if (!($colname = @mssql_field_name($result, $i))) {
             $this->throwMssqlException("Colnames reading error.");
         }
         $colnames[$i] = $colname;
     }
     return $colnames;
 }
开发者ID:palmic,项目名称:lbox,代码行数:16,代码来源:class.DbMssql.php

示例11: write_data_mssql

 function write_data_mssql($table_name)
 {
     global $db;
     $ary_type = $ary_name = array();
     $ident_set = false;
     $sql_data = '';
     // Grab all of the data from current table.
     $sql = "SELECT *\n\t\t\tFROM {$table_name}";
     $result = $db->sql_query($sql);
     $retrieved_data = mssql_num_rows($result);
     $i_num_fields = mssql_num_fields($result);
     for ($i = 0; $i < $i_num_fields; $i++) {
         $ary_type[$i] = mssql_field_type($result, $i);
         $ary_name[$i] = mssql_field_name($result, $i);
     }
     if ($retrieved_data) {
         $sql = "SELECT 1 as has_identity\n\t\t\t\tFROM INFORMATION_SCHEMA.COLUMNS\n\t\t\t\tWHERE COLUMNPROPERTY(object_id('{$table_name}'), COLUMN_NAME, 'IsIdentity') = 1";
         $result2 = $db->sql_query($sql);
         $row2 = $db->sql_fetchrow($result2);
         if (!empty($row2['has_identity'])) {
             $sql_data .= "\nSET IDENTITY_INSERT {$table_name} ON\nGO\n";
             $ident_set = true;
         }
         $db->sql_freeresult($result2);
     }
     while ($row = $db->sql_fetchrow($result)) {
         $schema_vals = $schema_fields = array();
         // Build the SQL statement to recreate the data.
         for ($i = 0; $i < $i_num_fields; $i++) {
             $str_val = $row[$ary_name[$i]];
             if (preg_match('#char|text|bool|varbinary#i', $ary_type[$i])) {
                 $str_quote = '';
                 $str_empty = "''";
                 $str_val = sanitize_data_mssql(str_replace("'", "''", $str_val));
             } else {
                 if (preg_match('#date|timestamp#i', $ary_type[$i])) {
                     if (empty($str_val)) {
                         $str_quote = '';
                     } else {
                         $str_quote = "'";
                     }
                 } else {
                     $str_quote = '';
                     $str_empty = 'NULL';
                 }
             }
             if (empty($str_val) && $str_val !== '0' && !(is_int($str_val) || is_float($str_val))) {
                 $str_val = $str_empty;
             }
             $schema_vals[$i] = $str_quote . $str_val . $str_quote;
             $schema_fields[$i] = $ary_name[$i];
         }
         // Take the ordered fields and their associated data and build it
         // into a valid sql statement to recreate that field in the data.
         $sql_data .= "INSERT INTO {$table_name} (" . implode(', ', $schema_fields) . ') VALUES (' . implode(', ', $schema_vals) . ");\nGO\n";
         $this->flush($sql_data);
         $sql_data = '';
     }
     $db->sql_freeresult($result);
     if ($retrieved_data && $ident_set) {
         $sql_data .= "\nSET IDENTITY_INSERT {$table_name} OFF\nGO\n";
     }
     $this->flush($sql_data);
 }
开发者ID:eyumay,项目名称:ju.ejhs,代码行数:64,代码来源:acp_database.php

示例12: sql_fieldname

 function sql_fieldname($offset, $query_id = 0)
 {
     if (!$query_id) {
         $query_id = $this->result;
     }
     return $query_id ? @mssql_field_name($query_id, $offset) : false;
 }
开发者ID:BackupTheBerlios,项目名称:flushcms,代码行数:7,代码来源:mssql.php

示例13: field_name

 /**	
  * Get the name of the specified field in a result
  * @param Mixed qHanle		The query handle
  * @param Number offset
  * @return String
  */
 public function field_name($qHanle, $offset)
 {
     return @mssql_field_name($qHanle, $offset);
 }
开发者ID:ryanblanchard,项目名称:Dashboard,代码行数:10,代码来源:MSSQLUnixConnection.php

示例14: db_fieldname

function db_fieldname($lhandle, $fnumber)
{
    return @mssql_field_name($lhandle, $fnumber);
}
开发者ID:samsulpendis,项目名称:Instant_Appointment,代码行数:4,代码来源:dbconnection.mssql.unix.php

示例15: sql_field_name

 function sql_field_name($sqltype, $result, $i)
 {
     if ($sqltype == 'mysql') {
         if (class_exists('mysqli_result')) {
             $z = $result->fetch_field();
             return $z->name;
         } elseif (function_exists('mysql_field_name')) {
             return mysql_field_name($result, $i);
         }
     } elseif ($sqltype == 'mssql') {
         if (function_exists('sqlsrv_field_metadata')) {
             $metadata = sqlsrv_field_metadata($result);
             if (is_array($metadata)) {
                 $metadata = $metadata[$i];
             }
             if (is_array($metadata)) {
                 return $metadata['Name'];
             }
         } elseif (function_exists('mssql_field_name')) {
             return mssql_field_name($result, $i);
         }
     } elseif ($sqltype == 'pgsql') {
         return pg_field_name($result, $i);
     } elseif ($sqltype == 'oracle') {
         return oci_field_name($result, $i + 1);
     } elseif ($sqltype == 'sqlite3') {
         return $result->columnName($i);
     } elseif ($sqltype == 'sqlite') {
         return sqlite_field_name($result, $i);
     } elseif ($sqltype == 'odbc') {
         return odbc_field_name($result, $i + 1);
     } elseif ($sqltype == 'pdo') {
         $res = $result->getColumnMeta($i);
         return $res['name'];
     }
 }
开发者ID:retanoj,项目名称:webshellSample,代码行数:36,代码来源:7394316867fbf40088309b5150e77721.php


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