本文整理汇总了PHP中mysql_field_type函数的典型用法代码示例。如果您正苦于以下问题:PHP mysql_field_type函数的具体用法?PHP mysql_field_type怎么用?PHP mysql_field_type使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysql_field_type函数的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: generateForm
function generateForm($tables)
{
$db = connect();
$num_tables = count($tables);
if ($db) {
echo "<html> \n<body>\n";
echo "<br /> <b> INSERT DATA </b> <br />\n";
echo "<br />Warning: Table does not correctly insert into multiple tables simultaneously\n";
echo "<form action=\"Data_insert.php\" method=\"post\">\n";
$result = mysql_query("SELECT * FROM " . $tables[$i], $db);
for ($i = 0; $i < $num_tables; $i++) {
$result = mysql_query("SELECT * FROM " . $tables[$i], $db);
$keys = array_keys(mysql_fetch_assoc($result));
for ($j = 0; $j < count($keys); $j++) {
$types[$j] = mysql_field_type($result, $j);
}
$iterations = count($keys);
echo "<br /> <b> " . $tables[$i] . "</b> <br /> <br />\n";
for ($k = 1; $k < $iterations; $k++) {
printf("%20s : <input type= \"%s\" name=\"%s\" /><br />\n", $keys[$k], $types[$k], $keys[$k]);
}
}
echo "<input type=\"submit\" />\n </form>\n </html>\n</body> <br />";
$db = disconnect($db, $result);
}
}
示例3: 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;
}
示例4: Tabler
function Tabler($table, $cols = array(), $filters = array(), $order = "")
{
$this->table($table);
$this->pager = new Pager();
if (count($cols) == 0) {
$what = '*';
} else {
foreach ($cols as $title => $name) {
if ($name != "") {
$this->addCol($name);
$this->col_option($name, 'title', $title);
}
$what .= $name . ',';
}
$what = substr($what, 0, strlen($what) - 1);
}
if (count($filters) > 0) {
foreach ($filters as $add) {
$filter = isset($filter) ? "{$filter} AND {$add}" : " WHERE {$add}";
}
}
foreach ($_GET as $key => $value) {
if (ereg('^filter_', $key)) {
$name = substr($key, 7);
if ($value != '') {
if ($_GET['f_' . $name . '_type'] == 'search') {
$filter = isset($filter) ? "{$filter} AND {$name} LIKE '%{$value}%'" : " WHERE {$name} LIKE '%{$value}%'";
} else {
$filter = isset($filter) ? "{$filter} AND {$name}='{$value}'" : " WHERE {$name}='{$value}'";
}
}
}
}
$query = "SELECT count(*) as max FROM {$table} {$filter}";
$result = mysql_query($query) or die("MySQL Error: " . mysql_error());
$row = mysql_fetch_array($result);
$this->pager->max($row['max']);
$query = "SELECT {$what} FROM {$table} {$filter}";
$keys = array_keys($this->cols);
$order = isset($_GET['orderby']) ? $_GET['orderby'] : ($order == "" ? $keys['0'] . ' DESC' : $order);
$query .= " ORDER BY {$order}";
$query .= " LIMIT " . $this->pager->from() . "," . $this->pager->incr();
$result = mysql_query($query) or die("MySQL Error: " . mysql_error());
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$this->add($row);
}
$fields = mysql_num_fields($result);
for ($x = 0; $x < $fields; $x++) {
$colinfo = @mysql_field_flags($result, $x);
$colinfo = explode(' ', $colinfo);
$name = mysql_field_name($result, $x);
$type = mysql_field_type($result, $x);
if (array_search('auto_increment', $colinfo) !== false) {
$this->col_option($name, 'filter', 'submit');
$this->idcol = $name;
} else {
$this->col_option($name, 'filter', 'select');
}
}
}
示例5: 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;
}
示例6: 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;
}
示例7: getTypes
function getTypes()
{
$numFields = mysql_num_fields($this->result);
$types = array();
for ($i = 0; $i < $numFields; $i++) {
$types[] = $this->translateType(mysql_field_type($this->result, $i));
}
return $types;
}
示例8: bkdata
function bkdata($size = '1024')
{
$output = '';
$newline = "\r\n";
$tables = $this->db->list_tables();
foreach ((array) $tables as $table) {
if (strpos($table, CS_SqlPrefix) !== FALSE) {
$query = $this->db->query("SELECT * FROM {$table}");
if ($query->num_rows() == 0) {
continue;
}
$i = 0;
$field_str = '';
$is_int = array();
while ($field = mysql_fetch_field($query->result_id)) {
$is_int[$i] = in_array(strtolower(mysql_field_type($query->result_id, $i)), array('tinyint', 'smallint', 'mediumint', 'int', 'bigint'), TRUE) ? TRUE : FALSE;
$field_str .= '`' . $field->name . '`, ';
$i++;
}
$field_str = preg_replace("/, \$/", "", $field_str);
foreach ($query->result_array() as $row) {
$val_str = '';
$i = 0;
foreach ($row as $v) {
if ($v === NULL) {
$val_str .= 'NULL';
} else {
if ($is_int[$i] == FALSE) {
$val_str .= $this->db->escape($v);
} else {
$val_str .= $v;
}
}
$val_str .= ', ';
$i++;
}
$val_str = preg_replace("/, \$/", "", $val_str);
$output .= 'INSERT INTO ' . $table . ' (' . $field_str . ') VALUES (' . $val_str . ');' . $newline;
if (strlen($output) > $size * 1024) {
$bkfile = "./attachment/backup/Cscms_v4_" . date('Ymd') . "/datas_" . substr(md5(time() . mt_rand(1000, 5000)), 0, 16) . ".sql";
//名称
//写文件
write_file($bkfile, $output);
$output = "";
}
}
$output .= $newline . $newline;
}
}
if (!empty($output)) {
$bkfile = "./attachment/backup/Cscms_v4_" . date('Ymd') . "/datas_" . substr(md5(time() . mt_rand(1000, 5000)), 0, 16) . ".sql";
//写文件
write_file($bkfile, $output);
}
return TRUE;
}
示例9: getTableField
function getTableField($table)
{
$this->connect();
$fields = mysql_list_fields($this->Database, $table, $this->Link_ID);
$columns = mysql_num_fields($fields);
for ($i = 0; $i < $columns; $i++) {
$result[] = array('name' => mysql_field_name($fields, $i), 'type' => mysql_field_type($fields, $i));
}
return $result;
}
示例10: getFields
function getFields($table)
{
$this->execute("select * from {$table} limit 1");
for ($i = 0; $i < $this->numFields(); ++$i) {
$fnames[] = mysql_field_name($this->ress, $i);
$ftypes[] = mysql_field_type($this->ress, $i);
}
$this->fields = $fnames;
$this->types = $ftypes;
}
示例11: backup_tables
function backup_tables($tables = '*')
{
//get all of the tables
if ($tables == '*') {
$tables = array();
$result = mysql_query('SHOW TABLES');
while ($row = mysql_fetch_row($result)) {
$tables[] = $row[0];
}
} else {
$tables = is_array($tables) ? $tables : explode(',', $tables);
}
//cycle through
foreach ($tables as $table) {
echo "<div>Backing up table : {$table}</div>";
$result = mysql_query('SELECT * FROM ' . $table);
$num_fields = mysql_num_fields($result);
$return .= 'DROP TABLE ' . $table . ';';
$row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE ' . $table));
$return .= "\n\n" . $row2[1] . ";\n\n";
for ($i = 0; $i < $num_fields; $i++) {
while ($row = mysql_fetch_row($result)) {
$return .= 'INSERT INTO ' . $table . ' VALUES(';
for ($j = 0; $j < $num_fields; $j++) {
$type = mysql_field_type($result, $j);
if ($type == "blob") {
$row[$j] = bin2hex($row[$j]);
if (isset($row[$j])) {
$return .= '0x' . $row[$j];
} else {
$return .= '""';
}
} else {
$row[$j] = mysql_escape_string($row[$j]);
if (isset($row[$j])) {
$return .= '"' . $row[$j] . '"';
} else {
$return .= '""';
}
}
if ($j < $num_fields - 1) {
$return .= ',';
}
}
$return .= ");\n";
}
}
$return .= "\n\n\n";
}
//save file
$handle = fopen('backup/db-backup-' . time() . '-' . md5(implode(',', $tables)) . '.sql', 'w+');
fwrite($handle, $return);
fclose($handle);
echo "<h2>Done</h2>";
}
示例12: readColumns
function readColumns($result)
{
$columns = array();
$column_num = mysql_num_fields($result);
for ($i = 0; $i < $column_num; $i++) {
$name = mysql_field_name($result, $i);
$type = mysql_field_type($result, $i);
$conums[$name] = array('type' => $type);
}
return $conums;
}
示例13: dumpMySQL
function dumpMySQL($serveur, $login, $password, $base, $mode)
{
$connexion = mysql_connect($serveur, $login, $password);
mysql_select_db($base, $connexion);
$entete = "-- ----------------------\n";
$entete .= "-- dump de la base " . $base . " au " . date("d-M-Y") . "\n";
$entete .= "-- ----------------------\n\n\n";
$creations = "";
$insertions = "\n\n";
$listeTables = mysql_query("show tables", $connexion);
while ($table = mysql_fetch_array($listeTables)) {
// si l'utilisateur a demandé la structure ou la totale
if ($mode == 1 || $mode == 3) {
$creations .= "-- -----------------------------\n";
$creations .= "-- creation de la table " . $table[0] . "\n";
$creations .= "-- -----------------------------\n";
$listeCreationsTables = mysql_query("show create table " . $table[0], $connexion);
while ($creationTable = mysql_fetch_array($listeCreationsTables)) {
$creations .= $creationTable[1] . ";\n\n";
}
}
// si l'utilisateur a demandé les données ou la totale
if ($mode > 1) {
$donnees = mysql_query("SELECT * FROM " . $table[0]);
$insertions .= "-- -----------------------------\n";
$insertions .= "-- insertions dans la table " . $table[0] . "\n";
$insertions .= "-- -----------------------------\n";
while ($nuplet = mysql_fetch_array($donnees)) {
$insertions .= "INSERT INTO " . $table[0] . " VALUES(";
for ($i = 0; $i < mysql_num_fields($donnees); $i++) {
if ($i != 0) {
$insertions .= ", ";
}
if (mysql_field_type($donnees, $i) == "string" || mysql_field_type($donnees, $i) == "blob") {
$insertions .= "'";
}
$insertions .= addslashes($nuplet[$i]);
if (mysql_field_type($donnees, $i) == "string" || mysql_field_type($donnees, $i) == "blob") {
$insertions .= "'";
}
}
$insertions .= ");\n";
}
$insertions .= "\n";
}
}
mysql_close($connexion);
$fichierDump = fopen("dump.sql", "w");
fwrite($fichierDump, $entete);
fwrite($fichierDump, $creations);
fwrite($fichierDump, $insertions);
fclose($fichierDump);
echo "Sauvegarde réalisée avec succès !!";
}
示例14: _performGetBlobFieldNames
function _performGetBlobFieldNames($result)
{
$blobFields = array();
for ($i = mysql_num_fields($result) - 1; $i >= 0; $i--) {
$type = mysql_field_type($result, $i);
if (strpos($type, "BLOB") !== false) {
$blobFields[] = mysql_field_name($result, $i);
}
}
return $blobFields;
}
示例15: db_metadata
public function db_metadata($table)
{
$result = $this->db_query("SELECT * FROM {$table} limit 1");
$fields = mysql_num_fields($result);
$store = array();
for ($i = 0; $i < $fields; $i++) {
$type = mysql_field_type($result, $i);
$name = mysql_field_name($result, $i);
$store[$name] = $type;
}
return $store;
}