本文整理汇总了PHP中mysql_field_table函数的典型用法代码示例。如果您正苦于以下问题:PHP mysql_field_table函数的具体用法?PHP mysql_field_table怎么用?PHP mysql_field_table使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysql_field_table函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: query
function query($query, $singleResult = 0) {
$this->_result = mysql_query($query, $this->_dbHandle);
if (preg_match("/select/i",$query)) {
$result = array();
$table = array();
$field = array();
$tempResults = array();
$numOfFields = mysql_num_fields($this->_result);
for ($i = 0; $i < $numOfFields; ++$i) {
array_push($table,mysql_field_table($this->_result, $i));
array_push($field,mysql_field_name($this->_result, $i));
}
while ($row = mysql_fetch_row($this->_result)) {
for ($i = 0;$i < $numOfFields; ++$i) {
$table[$i] = trim(ucfirst($table[$i]),"s");
$tempResults[$table[$i]][$field[$i]] = $row[$i];
}
if ($singleResult == 1) {
mysql_free_result($this->_result);
return $tempResults;
}
array_push($result,$tempResults);
}
mysql_free_result($this->_result);
return($result);
}
if(DB_DEVELOPMENT) echo mysql_errno($this->_dbHandle),' : ',mysql_error($this->_dbHandle), '\n';
}
示例3: query
/** 自定义SQL查询语句 **/
function query($query, $singleResult = 0)
{
$this->_result = mysql_query($query, $this->_dbHandle);
if (preg_match("/select/i", $query)) {
$result = array();
$table = array();
$field = array();
$tempResults = array();
$numOfFields = mysql_num_fields($this->_result);
//echo $numOfFields;
for ($i = 0; $i < $numOfFields; ++$i) {
array_push($table, mysql_field_table($this->_result, $i));
array_push($field, mysql_field_name($this->_result, $i));
}
while ($row = mysql_fetch_row($this->_result)) {
for ($i = 0; $i < $numOfFields; ++$i) {
$tempResults[$table[$i]][$field[$i]] = $row[$i];
}
if ($singleResult == 1) {
mysql_free_result($this->_result);
return $tempResults;
}
array_push($result, $tempResults);
}
mysql_free_result($this->_result);
//var_dump($result);
return $result;
}
}
示例4: query
function query($s = '', $rows = false, $organize = true)
{
if (!($q = mysql_query($s, $this->con))) {
return false;
}
if ($rows !== false) {
$rows = intval($rows);
}
$rez = array();
$count = 0;
$type = $organize ? MYSQL_NUM : MYSQL_ASSOC;
while (($rows === false || $count < $rows) && ($line = mysql_fetch_array($q, $type))) {
if ($organize) {
foreach ($line as $field_id => $value) {
$table = mysql_field_table($q, $field_id);
if ($table === '') {
$table = 0;
}
$field = mysql_field_name($q, $field_id);
$rez[$count][$table][$field] = $value;
}
} else {
$rez[$count] = $line;
}
++$count;
}
$this->num = $count;
if (!mysql_free_result($q)) {
return false;
}
return $rez;
}
示例5: f_ReturnArrayAssoc_TF
/**
* this returns a 2d associative array with the db "table.field" name as the first element
*
* @param string $sqlTemp
* @return array
*/
function f_ReturnArrayAssoc_TF($sqlTemp) {
$result = mysql_query ($sqlTemp);
if(mysql_errno() != 0) {
echo "f_ReturnArrayAssoc_TF<BR><BR>";
echo $sqlTemp . "<BR>";
echo "<BR><BR>" . mysql_errno() . ": " . mysql_error() . "<BR>\n";
exit;
}
$intNumColumns = mysql_num_fields($result) - 1; //make zero base
$intNumRecords = mysql_num_rows($result) - 1; //make zero base
//Get the table-column names
for ($i=0; $i <= $intNumColumns; $i++) {
$arrTableFieldStructure[$i][0] = mysql_field_table($result, $i) . "." . mysql_field_name($result, $i);
}
if ($intNumRecords > -1) {
//Put the data into the array
$arrData[0][0]; //Error preventor
$intRecord = -1; //initialize row counter
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
$intRecord++; //increment the counter
for($intColumn = 0;$intColumn <= $intNumColumns;$intColumn++){
$arrData[$arrTableFieldStructure[$intColumn][0]][$intRecord] = $row[$intColumn];
}
}
return $arrData;
} else {
return -1;
}
}
示例6: getRow
function getRow()
{
$rowData = array();
for ($f = 0; $f < @mysql_num_fields($this->result); $f++) {
$fieldName = @mysql_field_name($this->result, $f);
$fieldTable = @mysql_field_table($this->result, $f);
$rowData[$fieldTable . "." . $fieldName] = $this->row[$f];
//htmlentities($this->row[$f]);
}
return $rowData;
}
示例7: readKeys
function readKeys($result)
{
$keys = array('primary' => array(), 'foreign' => array());
$column_num = mysql_num_fields($result);
for ($i = 0; $i < $column_num; $i++) {
$column = mysql_field_name($result, $i);
$table = mysql_field_table($result, $i);
if (strpos(mysql_field_flags($result, $i), 'primary_key') > 0) {
$type = 'primary';
$keys[$type][$table] = array('type' => $type, 'table' => $table, 'column' => $column);
}
}
return $keys;
}
示例8: mysql_fetch_table
function mysql_fetch_table($result)
{
if (!($row = mysql_fetch_array($result))) {
return null;
}
$assoc = array();
$rowCount = mysql_num_fields($result);
for ($idx = 0; $idx < $rowCount; $idx++) {
$table = mysql_field_table($result, $idx);
$field = mysql_field_name($result, $idx);
echo $assoc["{$table}.{$field}"] = $row[$idx] . "<BR />";
}
return $assoc;
}
示例9: getRow
function getRow()
{
$rowData = array();
for ($f = 0; $f < mysql_num_fields($this->result); $f++) {
$fieldName = mysql_field_name($this->result, $f);
$fieldTable = mysql_field_table($this->result, $f);
//echo $fieldName."<br>";
//echo mb_detect_encoding($this->row[$f],"UTF-8, ISO-8859-1");
if (!in_array(mb_detect_encoding($this->row[$f], "UTF-8, ISO-8859-1"), array("UTF-8", "ISO-8859-1"))) {
$rowData[$fieldTable . "." . $fieldName] = mb_convert_encoding($this->row[$f], "UTF-8");
//htmlentities($this->row[$f]);
//echo "convirtiendo";
} else {
$rowData[$fieldTable . "." . $fieldName] = $this->row[$f];
//htmlentities($this->row[$f]);
}
// echo "<hr>";
}
return $rowData;
}
示例10: ddfield
function ddfield($table)
{
if (!empty($table)) {
$result = mysql_query("select * from {$table}");
$fields = mysql_num_fields($result);
$rows = mysql_num_rows($result);
$table = mysql_field_table($result, $k);
$k = 0;
echo "<b>Table Properties: Name: {$table}</b><br>";
echo "<table border='1' cellpadding='4' cellspacing='2' width='80%'><tr><td><b>Field Name</b></td><td><b>Field Type</b></td><td><b>Field Length</b></td><td><b>Field Flags<b></td></tr>";
while ($k < $fields) {
echo "<tr>";
$name = mysql_field_name($result, $k);
$type = mysql_field_type($result, $k);
$len = mysql_field_len($result, $k);
$flags = mysql_field_flags($result, $k);
echo "<td>" . $name . "</td><td>" . $type . "</td><td>" . $len . "</td><td>" . $flags . "</td>";
$k++;
echo "</tr>";
}
echo "</table>";
}
}
示例11: f_ReturnArrayAssoc_TF
/**
* this returns a 2d associative array with the db "table.field" name as the first element
*
* @param string $str_sql
* @return array
*/
function f_ReturnArrayAssoc_TF ($str_sql) {
//echo $str_sql . "<BR>f_ReturnArrayAssoc_TF<HR>";
$result = mysql_query($str_sql, $this->link);
if(mysql_errno($this->link) != 0) {
echo "f_ReturnArrayAssoc_TF<BR><BR>";
echo $str_sql . "<BR>";
echo "<BR><BR>" . mysql_errno($this->link) . ": " . mysql_error($this->link) . "<BR>\n";
exit;
}
$intNumColumns = mysql_num_fields($result) - 1; //make zero base
$intNumRecords = mysql_num_rows($result) - 1; //make zero base
//Get the table-column names
for ($i=0; $i <= $intNumColumns; $i++) {
//we should probalby "strtolower()" here but there is a lot of extant code that would break
$arrTableFieldStructure[$i][0] = mysql_field_table($result, $i) . "." . mysql_field_name($result, $i);
}
if ($intNumRecords > -1) {
//Put the data into the array
// $arrData[0][0]; //Error preventor
$intRecord = -1; //initialize row counter
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
$intRecord++; //increment the counter
for($intColumn = 0;$intColumn <= $intNumColumns;$intColumn++){
$arrData[$arrTableFieldStructure[$intColumn][0]][$intRecord] = $row[$intColumn];
}
}
mysql_free_result($result);
return $arrData;
} else {
return -1;
}
}
示例12: print_result
function print_result($RESULT) {
if(!$RESULT) return;
if(mysql_num_rows($RESULT) < 1) return;
$fieldcount = mysql_num_fields($RESULT);
for ($i=0; $i<$fieldcount; $i++) {
$tables[mysql_field_table($RESULT, $i)]++;
}
print '
<style type="text/css">
.rs_tb_th {
font-family: Verdana;
font-size:9pt;
font-weight:bold;
color:white;
}
.rs_f_th {
font-family:Verdana;
font-size:7pt;
font-weight:bold;
color:white;
}
.rs_td {
font-family:Verdana;
font-size:7pt;
}
</style>
<script type="text/javascript" language="JavaScript">
var lastID;
function highlight(id) {
if(lastID) {
lastID.style.color = "#000000";
lastID.style.textDecoration = "none";
}
tdToHighlight = document.getElementById(id);
tdToHighlight.style.color ="#FF0000";
tdToHighlight.style.textDecoration = "underline";
lastID = tdToHighlight;
}
</script>
';
print '<table bgcolor="#000000" cellspacing="1" cellpadding="1">';
print '<tr>';
foreach ($tables as $tableName => $tableCount) {
$col == '0054A6' ? $col = '003471' : $col = '0054A6';
print '<th colspan="'.$tableCount.'" class="rs_tb_th" style="background-color:#'.$col.';">'.$tableName.'</th>';
}
print '</tr>';
print '<tr>';
for ($i=0;$i < mysql_num_fields($RESULT);$i++) {
$FIELD = mysql_field_name($RESULT, $i);
$col == '0054A6' ? $col = '003471' : $col = '0054A6';
print '<td align="center" bgcolor="#'.$col.'" class="rs_f_th">'.$FIELD.'</td>';
}
print '</tr>';
mysql_data_seek($RESULT, 0);
while ($DB_ROW = mysql_fetch_array($RESULT, MYSQL_NUM)) {
$pointer++;
if($toggle) {
$col1 = "E6E6E6";
$col2 = "DADADA";
} else {
$col1 = "E1F0FF";
$col2 = "DAE8F7";
}
$toggle = !$toggle;
print '<tr id="ROW'.$pointer.'" onMouseDown="highlight(\'ROW'.$pointer.'\');">';
foreach ($DB_ROW as $value) {
$col == $col1 ? $col = $col2 : $col = $col1;
print '<td valign="top" bgcolor="#'.$col.'" class="rs_td" nowrap>'.nl2br($value).'</td>';
}
print '</tr>';
}
print '</table>';
mysql_data_seek($RESULT, 0);
}
示例13: MySQL_Field_Table_Test
/**
* Test mysql_field_table
*
* @return boolean
*/
public function MySQL_Field_Table_Test()
{
// Select Db
$this->_selectDb();
// Query
$sql = 'SELECT * FROM ' . TEST_TABLE . ' LIMIT 1';
// Query
$query1 = mysql_query($sql);
$query2 = $this->_object->mysql_query($sql);
// Get items
$table1 = mysql_field_table($query1, 0);
$table2 = $this->_object->mysql_field_table($query2, 0);
return $table1 === $table2;
}
示例14: mysql_fieldtable
function mysql_fieldtable(...$args)
{
return mysql_field_table(...$args);
}
示例15: EchoFieldsHeader
function EchoFieldsHeader($res, $numfields)
{
$str = "";
for( $i = 0; $i < $numfields; $i++ ) {
$str .= GetBlock(mysql_field_name($res, $i));
$str .= GetBlock(mysql_field_table($res, $i));
$type = mysql_field_type($res, $i);
$length = mysql_field_len($res, $i);
switch ($type) {
case "int":
if( $length > 11 ) $type = 8;
else $type = 3;
break;
case "real":
if( $length == 12 ) $type = 4;
elseif( $length == 22 ) $type = 5;
else $type = 0;
break;
case "null":
$type = 6;
break;
case "timestamp":
$type = 7;
break;
case "date":
$type = 10;
break;
case "time":
$type = 11;
break;
case "datetime":
$type = 12;
break;
case "year":
$type = 13;
break;
case "blob":
if( $length > 16777215 ) $type = 251;
elseif( $length > 65535 ) $type = 250;
elseif( $length > 255 ) $type = 252;
else $type = 249;
break;
default:
$type = 253;
}
$str .= GetLongBinary($type);
$flags = explode( " ", mysql_field_flags ( $res, $i ) );
$intflag = 0;
if(in_array( "not_null", $flags )) $intflag += 1;
if(in_array( "primary_key", $flags )) $intflag += 2;
if(in_array( "unique_key", $flags )) $intflag += 4;
if(in_array( "multiple_key", $flags )) $intflag += 8;
if(in_array( "blob", $flags )) $intflag += 16;
if(in_array( "unsigned", $flags )) $intflag += 32;
if(in_array( "zerofill", $flags )) $intflag += 64;
if(in_array( "binary", $flags)) $intflag += 128;
if(in_array( "enum", $flags )) $intflag += 256;
if(in_array( "auto_increment", $flags )) $intflag += 512;
if(in_array( "timestamp", $flags )) $intflag += 1024;
if(in_array( "set", $flags )) $intflag += 2048;
$str .= GetLongBinary($intflag);
$str .= GetLongBinary($length);
}
echo $str;
}