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


PHP mysql_field_name函数代码示例

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


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

示例1: fetchArrayStrict

 public function fetchArrayStrict($sql = null)
 {
     if (empty($sql)) {
         throw new DbException('<b>SQL ERROR</b> : null query ! <br>');
     }
     $query = $this->query($sql);
     if ($query === false) {
         return null;
     }
     $confunc = $this->connect->getDbStyle() . '_fetch_array';
     while ($arr = $confunc($query)) {
         $array[] = $arr;
     }
     if (!is_array($array)) {
         return null;
     }
     foreach ($array as $k => $v) {
         foreach ($v as $kk => $vv) {
             if (!is_numeric($kk)) {
                 continue;
             }
             $type = mysql_field_type($query, $kk);
             $name = mysql_field_name($query, $kk);
             if ($type == 'int') {
                 $arr[$k][$name] = (int) $vv;
             } else {
                 $arr[$k][$name] = $vv;
             }
         }
     }
     return $arr;
 }
开发者ID:tiger2soft,项目名称:LycPHP,代码行数:32,代码来源:Manager.class.php

示例2: WriteHistoryFromSQL

/**
 * INPUT: $apikey
 * OUTPUT: XML file
 **/
function WriteHistoryFromSQL($sql)
{
    $req = mysql_query($sql) or die('SQL Error !<br>' . $sql . '<br>' . mysql_error());
    $f = mysql_num_fields($req);
    for ($i = 0; $i < $f; $i++) {
        $previous[$i] = "";
        $xmltab[$i] = "";
    }
    while ($data = mysql_fetch_array($req)) {
        for ($i = 0; $i < $f; $i++) {
            if (mysql_field_name($req, $i) != 'cid' && mysql_field_name($req, $i) != 'date' && $data[$i] != $previous[$i]) {
                $previous[$i] = $data[$i];
                $xmltab[$i] .= "<" . mysql_field_name($req, $i) . " date=\"" . $data['date'] . "\">" . $data[$i] . "</" . mysql_field_name($req, $i) . ">";
            }
        }
    }
    for ($i = 0; $i < $f; $i++) {
        $tag_name = mysql_field_name($req, $i);
        if ($tag_name != 'cid' && $tag_name != 'date') {
            if ($xmltab[$i] != "") {
                print "<" . $tag_name . "_history>" . $xmltab[$i] . "</" . $tag_name . "_history>";
            }
        }
    }
}
开发者ID:phantase,项目名称:ARMA,代码行数:29,代码来源:character_history_xml.inc.php

示例3: get_field_names

function get_field_names($table){
	$result = mysql_query("SELECT * FROM ".$table);
	for($x = 0; $x < mysql_num_fields($result); $x++){
		$arr[$x] = mysql_field_name($result,$x);
	}
	return $arr;
}
开发者ID:bernhardkircher,项目名称:installation-kircher-old,代码行数:7,代码来源:func.inc.php

示例4: update_emp_values

function update_emp_values($emp_type, $emp_id, $fname, $lname, $contact, $address, $salary, $sex, $bdate, $join_date)
{
    $dbc = mysql_connect('localhost', 'root', 'rishi');
    if (!$dbc) {
        die('NOT CONNECTED:' . mysql_error());
    }
    $db_selected = mysql_select_db("restaurant", $dbc);
    if (!$db_selected) {
        die('NOT CONNECTED TO DATABASE:' . mysql_error());
    }
    $emp_type_id = $emp_type . "_id";
    $query = "Select * from {$emp_type}";
    $emp = mysql_query($query);
    $num_fields = mysql_num_fields($emp);
    if ($emp_type == "COOK") {
        $val_arrays = array("{$emp_id}", $fname, $lname, $contact, $address, $salary, $sex, $bdate, $join_date, $_POST["Specialization"]);
    } else {
        $val_arrays = array("{$emp_id}", $fname, $lname, $contact, $address, $salary, $sex, $bdate, $join_date);
    }
    $values = "";
    for ($i = 1; $i < $num_fields; $i++) {
        $values = $values . mysql_field_name($emp, $i) . " = " . "\"{$val_arrays[$i]}\"";
        if ($i != $num_fields - 1) {
            $values = $values . " , ";
        }
    }
    $query = "UPDATE {$emp_type} SET " . $values . "  WHERE {$emp_type_id} = {$emp_id};";
    mysql_query($query);
}
开发者ID:tjanh123,项目名称:Restaurant-Management-Ordering-System,代码行数:29,代码来源:update_employee_values.php

示例5: mysqlfAdapter

 /**
  * 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 mysqlfAdapter($d)
 {
     $f = $d['filter'];
     $d = $d['data'];
     parent::RecordSetAdapter($d);
     $fieldcount = count($f);
     $truefieldcount = mysql_num_fields($d);
     $be = $this->isBigEndian;
     $isintcache = array();
     for ($i = 0; $i < $truefieldcount; $i++) {
         //mysql_fetch_* usually returns only strings,
         //hack it into submission
         $type = mysql_field_type($d, $i);
         $name = mysql_field_name($d, $i);
         $isintcache[$name] = in_array($type, array('int', 'real', 'year'));
     }
     $isint = array();
     for ($i = 0; $i < $fieldcount; $i++) {
         $this->columnNames[$i] = $this->_charsetHandler->transliterate($f[$i]);
         $isint[$i] = isset($isintcache[$f[$i]]) && $isintcache[$f[$i]];
     }
     //Start fast serializing
     $ob = "";
     $fc = pack('N', $fieldcount);
     if (mysql_num_rows($d) > 0) {
         mysql_data_seek($d, 0);
         while ($line = mysql_fetch_assoc($d)) {
             //Write array flag + length
             $ob .= "\n" . $fc;
             $i = 0;
             foreach ($f as $key) {
                 $value = $line[$key];
                 if (!$isint[$i]) {
                     $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;
                     }
                 } else {
                     $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;
                 }
                 $i++;
             }
         }
     }
     $this->numRows = mysql_num_rows($d);
     $this->serializedData = $ob;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:66,代码来源:mysqlfAdapter.php

示例6: RunFreeQuery

function RunFreeQuery()
{
    global $cnInfoCentral;
    global $aRowClass;
    global $rsQueryResults;
    global $sSQL;
    global $iQueryID;
    //Run the SQL
    $rsQueryResults = RunQuery($sSQL);
    if (mysql_error() != "") {
        echo gettext("An error occured: ") . mysql_errno() . "--" . mysql_error();
    } else {
        $sRowClass = "RowColorA";
        echo "<table align=\"center\" cellpadding=\"5\" cellspacing=\"0\">";
        echo "<tr class=\"" . $sRowClass . "\">";
        //Loop through the fields and write the header row
        for ($iCount = 0; $iCount < mysql_num_fields($rsQueryResults); $iCount++) {
            echo "<td align=\"center\"><b>" . mysql_field_name($rsQueryResults, $iCount) . "</b></td>";
        }
        echo "</tr>";
        //Loop through the recordsert
        while ($aRow = mysql_fetch_array($rsQueryResults)) {
            $sRowClass = AlternateRowStyle($sRowClass);
            echo "<tr class=\"" . $sRowClass . "\">";
            //Loop through the fields and write each one
            for ($iCount = 0; $iCount < mysql_num_fields($rsQueryResults); $iCount++) {
                echo "<td align=\"center\">" . $aRow[$iCount] . "</td>";
            }
            echo "</tr>";
        }
        echo "</table>";
        echo "<br><p class=\"ShadedBox\" style=\"border-style: solid; margin-left: 50px; margin-right: 50 px; border-width: 1px;\"><span class=\"SmallText\">" . str_replace(Chr(13), "<br>", htmlspecialchars($sSQL)) . "</span></p>";
    }
}
开发者ID:vikingkarwur,项目名称:smjgpib,代码行数:34,代码来源:QuerySQL.php

示例7: ListIt

 function ListIt()
 {
     $tmpstr = "";
     $query = "";
     global $strCantQuery;
     global $strNoContent;
     if (isset($this->headerfmt)) {
         $tmpstr = $this->headerfmt;
     }
     $query = "select " . $this->fields . " from " . $this->tables . " limit " . $this->startrow . ", " . $this->maxrow;
     $this->sqlres = mysql_query($query) or die("{$strCantQuery}: {$query} <br>Error: " . mysql_error());
     // ambil nama2 field
     $numfields = mysql_num_fields($this->sqlres);
     for ($cl = 0; $cl < $numfields; $cl++) {
         $arrfields[$cl] = mysql_field_name($this->sqlres, $cl);
         //echo $arrfields [$cl] . "<br>";
     }
     $nomer = 0;
     while ($row = mysql_fetch_array($this->sqlres)) {
         $tmp = $this->detailfmt;
         $nomer++;
         for ($cl = 0; $cl < $numfields; $cl++) {
             settype($nomer, "string");
             $tmp = str_replace("=NOMER=", $nomer, $tmp);
             $nmf = $arrfields[$cl];
             $tmp = str_replace("=" . $nmf . "=", $row[$nmf], $tmp);
             $tmp = str_replace("=!" . $nmf . "=", StripEmpty(urlencode($row[$nmf])), $tmp);
             $tmp = str_replace("=:" . $nmf . "=", StripEmpty(stripslashes($row[$nmf])), $tmp);
         }
         $tmpstr = $tmpstr . $tmp;
     }
     $tmpstr = $tmpstr . $this->footerfmt;
     return $tmpstr;
 }
开发者ID:anggadjava,项目名称:sisfor,代码行数:34,代码来源:lister.class.php

示例8: getAccessInfo

function getAccessInfo($sql_fields, $sql_table, $sql_conditions = "1", $cond = NULL)
{
    $access['Data'] = array();
    $access['Headers'] = 0;
    $access['Sql_Fields'] = $sql_fields;
    $access['Sql_Table'] = $sql_table;
    $access['Sql_Conditions'] = $sql_conditions;
    $sql = "Select {$sql_fields} from {$sql_table} where {$sql_conditions}";
    $result = sql_query_read($sql) or dieLog(mysql_error() . " ~ " . "<pre>{$sql}</pre>");
    if (mysql_num_rows($result) < 1) {
        return -1;
    }
    $row = mysql_fetch_row($result);
    $fields = mysql_num_fields($result);
    for ($i = 0; $i < $fields; $i++) {
        $type = mysql_field_type($result, $i);
        $name = mysql_field_name($result, $i);
        $len = mysql_field_len($result, $i);
        $flags = mysql_field_flags($result, $i);
        $table = mysql_field_table($result, $i);
        $useName = $name;
        if (array_key_exists($useName, $access['Data'])) {
            $useName = $name . $i;
        }
        if ($name == 'access_header') {
            $access['Headers']++;
        }
        $access['Data'][$useName] = getAttrib($name, $type, $len, $flags, $table, $row[$i], &$cond);
    }
    return $access;
}
开发者ID:juliogallardo1326,项目名称:proc,代码行数:31,代码来源:____updateAccess.old.php

示例9: query

 function query($query, $report = false)
 {
     $result = mysql_query($query, $this->link);
     $this->affected_rows = mysql_affected_rows($this->link);
     $this->insert_id = mysql_insert_id($this->link);
     if (!is_resource($result)) {
         if ($result == false && $report == true) {
             echo mysql_error();
         }
         return $result;
     } else {
         $numRows = mysql_num_rows($result);
         if ($numRows == 0) {
             return false;
         }
         $numFields = mysql_num_fields($result);
         for ($i = 0; $i < $numFields; $i++) {
             $resultFields[] = mysql_field_name($result, $i);
         }
         for ($i = 0; $i < $numRows; $i++) {
             $resultValues = mysql_fetch_row($result);
             $results[] = array_combine($resultFields, $resultValues);
         }
         return $results;
     }
 }
开发者ID:re5et,项目名称:mlurl,代码行数:26,代码来源:db.php

示例10: field_data

 /**
  * Field data
  *
  * Generates an array of objects containing field meta-data
  *
  * @access	public
  * @return	array
  */
 function field_data()
 {
     $retval = array();
     for ($i = 0, $c = $this->num_fields(); $i < $c; $i++) {
         $retval[$i] = new stdClass();
         $retval[$i]->name = mysql_field_name($this->result_id, $i);
         $retval[$i]->type = mysql_field_type($this->result_id, $i);
         $retval[$i]->max_length = mysql_field_len($this->result_id, $i);
         $retval[$i]->primary_key = strpos(mysql_field_flags($this->result_id, $i), 'primary_key') === FALSE ? 0 : 1;
         $retval[$i]->default = '';
     }
     /** Updated from github, see https://github.com/EllisLab/CodeIgniter/commit/effd0133b3fa805e21ec934196e8e7d75608ba00
     		while ($field = mysql_fetch_object($this->result_id))
     		{
     			preg_match('/([a-zA-Z]+)(\(\d+\))?/', $field->Type, $matches);
     
     			$type = (array_key_exists(1, $matches)) ? $matches[1] : NULL;
     			$length = (array_key_exists(2, $matches)) ? preg_replace('/[^\d]/', '', $matches[2]) : NULL;
     
     			$F				= new stdClass();
     			$F->name		= $field->Field;
     			$F->type		= $type;
     			$F->default		= $field->Default;
     			$F->max_length	= $length;
     			$F->primary_key = ( $field->Key == 'PRI' ? 1 : 0 );
     
     			$retval[] = $F;
     		}
     **/
     return $retval;
 }
开发者ID:jaksmid,项目名称:website,代码行数:39,代码来源:mysql_result.php

示例11: export_excel_csv

function export_excel_csv()
{
    $conn = mysql_connect("oblogin.com", "neel099_root", "rootdb");
    $db = mysql_select_db("neel099_twofactorauth", $conn);
    $sql = "SELECT * FROM Llog";
    $rec = mysql_query($sql) or die(mysql_error());
    $num_fields = mysql_num_fields($rec);
    for ($i = 0; $i < $num_fields; $i++) {
        $header .= mysql_field_name($rec, $i) . "\\t";
    }
    while ($row = mysql_fetch_row($rec)) {
        $line = '';
        foreach ($row as $value) {
            if (!isset($value) || $value == "") {
                $value = "\\t";
            } else {
                $value = str_replace('"', '""', $value);
                $value = '"' . $value . '"' . "\\t";
            }
            $line .= $value;
        }
        $data .= trim($line) . "\\n";
    }
    $data = str_replace("\\r", "", $data);
    if ($data == "") {
        $data = "\\n No Record Found!\n";
    }
    header("Content-type: application/octet-stream");
    header("Content-Disposition: attachment; filename=reports.xls");
    header("Pragma: no-cache");
    header("Expires: 0");
    print "{$header}\\n{$data}";
}
开发者ID:NikolaosHadjitheophanous,项目名称:2156764h_prototype,代码行数:33,代码来源:results.php

示例12: select

 function select($query, $class = 'recordset', $cache = true)
 {
     if (!$this->con_id) {
         return false;
     }
     if ($class == '' || !class_exists($class)) {
         $class = 'recordset';
     }
     if ($cache && ($rs = $this->_getFromCache($query)) !== false) {
         return new $class($rs);
     } else {
         $cur = mysql_unbuffered_query($query, $this->con_id);
         if ($cur) {
             # Insertion dans le reccordset
             $i = 0;
             $arryRes = array();
             while ($res = mysql_fetch_row($cur)) {
                 for ($j = 0; $j < count($res); $j++) {
                     $arryRes[$i][strtolower(mysql_field_name($cur, $j))] = $res[$j];
                 }
                 $i++;
             }
             $this->_putInCache($query, $arryRes);
             return new $class($arryRes);
         } else {
             $this->setError();
             return false;
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:kermert-svn,代码行数:30,代码来源:class.mysql.php

示例13: export2csv

function export2csv($params)
{
    $export = $params['rows'];
    $filename = $params['filename'];
    include_once "../config/db_conn.php";
    $fields = mysql_num_fields($export);
    for ($i = 0; $i < $fields; $i++) {
        $header .= mysql_field_name($export, $i) . ",";
    }
    while ($row = mysql_fetch_object($export)) {
        $line = '';
        foreach ($row as $value) {
            if (!isset($value) or $value == "") {
                $value = ",";
            } else {
                $value = str_replace('"', '""', $value);
                $value = '"' . $value . '"' . ",";
            }
            $line .= $value;
        }
        $data .= trim($line) . "\n";
    }
    //$data = str_replace("r","",$data);
    if ($data == "") {
        $data = "n(0) Records Found!n";
    }
    header("Content-type: application/x-msdownload");
    header("Content-Disposition: attachment; filename=" . $filename . ".csv");
    header("Pragma: no-cache");
    header("Expires: 0");
    print " {$header}\n{$data}";
}
开发者ID:jcandrew1966,项目名称:as_woodhouse,代码行数:32,代码来源:export2csv.php

示例14: printIt

 function printIt()
 {
     //[s.6]
     $num_cols = mysql_num_fields($this->result);
     $num_rows = mysql_num_rows($this->result);
     print "<h3>";
     //print field names
     print "<pre>";
     for ($i = 0; $i < $num_cols; $i++) {
         print mysql_field_name($this->result, $i);
         print "\t";
     }
     print "</pre>";
     print "</h3>";
     print "<p>";
     print "<pre>";
     mysql_data_seek($this->result, 0);
     for ($i = 0; $i < $num_rows; $i++) {
         $row = mysql_fetch_row($this->result);
         for ($j = 0; $j < $num_cols; $j++) {
             print $row[$j];
             print "\t";
         }
         print "<br>";
     }
     print "</pre>";
     print "</p>";
 }
开发者ID:dpsyche,项目名称:Tic-Tac-Toe,代码行数:28,代码来源:Query.php

示例15: getSqlResultAsXml

function getSqlResultAsXml($dbCon, $SQL_query)
{
    // Replace by a query that matches your database
    $result = $dbCon->executeQuery($SQL_query);
    // we produce XML
    header("Content-type: text/xml");
    $XML = "<?xml version=\"1.0\"?>\n";
    if (isset($xslt_file) && $xslt_file) {
        $XML .= "<?xml-stylesheet href=\"{$xslt_file}\" type=\"text/xsl\" ?>";
    }
    // root node
    $XML .= "<result>\n";
    // rows
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        $XML .= "\t<row>\n";
        $i = 0;
        // cells
        foreach ($row as $cell) {
            // Escaping illegal characters - not tested actually ;)
            $cell = str_replace("<", "&lt;", $cell);
            $cell = str_replace(">", "&gt;", $cell);
            $cell = str_replace("\"", "&quot;", $cell);
            //$cell = str_replace("&", "<![CDATA["."&"."]]>", $cell);
            $col_name = mysql_field_name($result, $i);
            // creates the "<tag>contents</tag>" representing the column
            $XML .= "\t\t<" . $col_name . ">" . $cell . "</" . $col_name . ">\n";
            $i++;
        }
        $XML .= "\t</row>\n";
    }
    $XML .= "</result>\n";
    // output the whole XML string
    return $XML;
}
开发者ID:CyborgOne,项目名称:cybihomecontrol_ui,代码行数:34,代码来源:xslt_functions.php


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