本文整理汇总了PHP中mysql_field_flags函数的典型用法代码示例。如果您正苦于以下问题:PHP mysql_field_flags函数的具体用法?PHP mysql_field_flags怎么用?PHP mysql_field_flags使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysql_field_flags函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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');
}
}
}
示例2: 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;
}
示例3: 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;
}
示例4: getColumnMeta
public function getColumnMeta($column)
{
if ($column >= $this->columnCount()) {
return false;
}
$info = mysql_fetch_field($this->_result, $column);
$result = array();
if ($info->def) {
$result['mysql:def'] = $info->def;
}
$result['native_type'] = $info->type;
$result['flags'] = explode(' ', mysql_field_flags($this->_result, $column));
$result['table'] = $info->table;
$result['name'] = $info->name;
$result['len'] = mysql_field_len($this->_result, $column);
$result['precision'] = 0;
switch ($result['native_type']) {
// seems like pdo_mysql treats everything as a string
/*
* case 'int': case 'real': $pdo_type =
* EhrlichAndreas_Pdo_Abstract::PARAM_INT; break; case 'blob': $pdo_type =
* EhrlichAndreas_Pdo_Abstract::PARAM_LOB; break; case 'null': $pdo_type =
* EhrlichAndreas_Pdo_Abstract::PARAM_NULL; break;
*/
default:
$pdo_type = EhrlichAndreas_Pdo_Abstract::PARAM_STR;
break;
}
$result['pdo_type'] = $pdo_type;
return $result;
}
示例5: getFieldFlags
public function getFieldFlags($_model, $_variable_name)
{
$_result = mysql_query('SHOW COLUMNS FROM ' . strtolower($_model) . ' WHERE Field = "' . $_variable_name . '";');
if (mysql_num_rows($_result) != 0) {
return mysql_field_flags($_result, 0);
}
return false;
}
示例6: checkBin
/**
* 1.4 betas were missing the 'binary' marker from logging.log_title,
* which causes a collation mismatch error on joins in MySQL 4.1.
*
* @param $table String: table name
* @param $field String: field name to check
* @param $patchFile String: path to the patch to correct the field
*/
protected function checkBin($table, $field, $patchFile)
{
$tableName = $this->db->tableName($table);
$res = $this->db->query("SELECT {$field} FROM {$tableName} LIMIT 0", __METHOD__);
$flags = explode(' ', mysql_field_flags($res->result, 0));
if (in_array('binary', $flags)) {
$this->output("...{$table} table has correct {$field} encoding.\n");
} else {
$this->applyPatch($patchFile, false, "Fixing {$field} encoding on {$table} table");
}
}
示例7: get_fields
function get_fields($query_id)
{
$fields = $this->num_fields($query_id);
$rows = $this->num_rows($query_id);
for ($i = 0; $i < $fields; $i++) {
$field[$i]->type = mysql_field_type($query_id, $i);
$field[$i]->name = mysql_field_name($query_id, $i);
$field[$i]->len = mysql_field_len($query_id, $i);
$field[$i]->flags = mysql_field_flags($query_id, $i);
}
return $field;
}
示例8: getTablePrimeKey
function getTablePrimeKey($pTable)
{
$this->connectDB();
$fields = mysql_list_fields($this->mDatabaseName, $pTable, $this->mLink);
$columns = mysql_num_fields($fields);
for ($i = 0; $i < $columns; $i++) {
$field_name = mysql_field_name($fields, $i);
if (in_array("primary_key", explode(" ", mysql_field_flags($fields, $i)))) {
$return[] = $field_name;
}
}
return $return;
}
示例9: 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;
}
示例10: mysql_field_len
case "mysql":
$ret = mysql_field_len($result, $offset);
break;
case "mysqli":
$tmp = mysqli_fetch_field_direct($result, $offset);
$ret = $tmp->length;
break;
}
return $ret;
}
function yog_mysql_field_flags($result, $offset)
{
//Get the flags associated with the specified field in a result
$ret = 0;
switch (DB_EXTENSION) {
case "mysql":
示例11: meta
function meta($table, $schema = "DEFAULT") {
$db = $GLOBALS["CFG_DB"]->CON[$schema]->DB;
$link = MysqlDriver::connect($schema);
$result = mysql_list_fields($db, $table, $link);
$count = mysql_num_fields($result);
$fields = array();
for($i = 0; $i < $count; $i++) {
$field["name"] = mysql_field_name($result, $i);
$field["length"] = mysql_field_len($result, $i);
$field["type"] = mysql_field_type($result, $i);
$field["flags"] = mysql_field_flags($result, $i);
$fields[] = $field;
}
mysql_free_result($result);
return $fields;
}
示例12: db_getfieldslist
/**
* @param String strSQL
* @return Array
*/
public function db_getfieldslist($strSQL)
{
$res = array();
$qResult = $this->connectionObj->query($strSQL);
$qHandle = $qResult->getQueryHandle();
$fieldsNumber = $qResult->numFields();
for ($i = 0; $i < $fieldsNumber; $i++) {
$stype = mysql_field_type($qHandle, $i);
if ($stype == "blob") {
$flags = mysql_field_flags($qHandle, $i);
if (strpos($flags, "binary") === false) {
$stype = "text";
}
}
$ntype = $this->getFieldTypeNumber($stype);
$res[$i] = array("fieldname" => $qResult->fieldName($i), "type" => $ntype, "not_null" => 0);
}
return $res;
}
示例13: create_header
function create_header()
{
$fields = mysql_list_fields($this->db, $this->table, $this->cnx);
$h = "CREATE TABLE `" . $this->table . "` (";
for ($i = 0; $i < mysql_num_fields($fields); $i++) {
$name = mysql_field_name($fields, $i);
$flags = mysql_field_flags($fields, $i);
$len = mysql_field_len($fields, $i);
$type = mysql_field_type($fields, $i);
$h .= "`{$name}` {$type}({$len}) {$flags},";
if (strpos($flags, "primary_key")) {
$pkey = " PRIMARY KEY (`{$name}`)";
}
}
$h = substr($h, 0, strlen($d) - 1);
$h .= "{$pkey}) TYPE=InnoDB;\n\n";
// echo "<p>--- Table data<br>$h</p>";
return $h;
}
示例14: getPrimaryFieldName
function getPrimaryFieldName($table_name)
{
global $db;
$field = false;
$sql = "SELECT * FROM " . TABLE_PREFIX . $table_name . ' WHERE 0';
$result = mysql_query($sql, $db);
$num_fields = mysql_num_fields($result);
for ($i = 0; $i < $num_fields; $i++) {
$flags = explode(' ', mysql_field_flags($result, $i));
if (in_array('primary_key', $flags)) {
if ($field == false) {
$field = mysql_field_name($result, $i);
} else {
// there is more than one primary_key
return NULL;
}
}
}
return $field;
}
示例15: build
public function build()
{
$db = Database::get_instance();
$values = $this->current_object->get_fields();
$options = array();
foreach ($values as $value) {
$res = $db->query('SELECT `' . $value . '` FROM ' . $this->table)->result;
$type = mysql_field_type($res, 0);
$extra = mysql_field_flags($res, 0);
$notnullsearch = strpos($extra, 'not_null');
// If value can not be NULL lets add blank as a error check
if ($notnullsearch === false) {
$options['validation'] = '';
} else {
$options['validation'] = 'blank';
}
$options['type'] = $type === 'blob' ? 'htmleditor' : 'text';
$options['type'] = $type === 'timestamp' ? 'timestamp' : $options['type'];
$options['type'] = $value === 'password' ? 'password' : $options['type'];
// Grab rows where field name matches
$value_info = new Field_Information(array('table' => $this->table, 'name' => $value));
if ($value_info->type !== NULL) {
$options['type'] = $value_info->type;
if ($options['type'] === 'file') {
// shouldn't validate for blank if it's a file.... TODO: Come up with a way to validate files
$options['validation'] = '';
}
}
if ($value_info->options !== NULL) {
$exploded_options = explode("\n", $value_info->options);
foreach ($exploded_options as $option) {
if (!empty($option)) {
$option_temp = explode(',', $option);
$options['options'][$option_temp[0]] = $option_temp[1];
}
}
}
$options['value'] = $this->current_object->{$value};
$this->add_field($value, $options);
}
}