本文整理汇总了PHP中mysql_field_len函数的典型用法代码示例。如果您正苦于以下问题:PHP mysql_field_len函数的具体用法?PHP mysql_field_len怎么用?PHP mysql_field_len使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysql_field_len函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: import
function import($data)
{
// cette méthode prend en entrée un tableau constitué des informations suivantes :
// $data['statut_libelle']
// $data['pret_flag']
// $data['statusdoc_codage_import']
// $data['statusdoc_owner']
global $dbh;
// check sur le type de la variable passée en paramètre
if (!sizeof($data) || !is_array($data)) {
// si ce n'est pas un tableau ou un tableau vide, on retourne 0
return 0;
}
// check sur les éléments du tableau
$long_maxi = mysql_field_len(mysql_query("SELECT statut_libelle FROM docs_statut limit 1"), 0);
$data['statut_libelle'] = rtrim(substr(preg_replace('/\\[|\\]/', '', rtrim(ltrim($data['statut_libelle']))), 0, $long_maxi));
$long_maxi = mysql_field_len(mysql_query("SELECT statusdoc_codage_import FROM docs_statut limit 1"), 0);
$data['statusdoc_codage_import'] = rtrim(substr(preg_replace('/\\[|\\]/', '', rtrim(ltrim($data['statusdoc_codage_import']))), 0, $long_maxi));
if ($data['statusdoc_owner'] == "") {
$data['statusdoc_owner'] = 0;
}
if ($data['statut_libelle'] == "") {
return 0;
}
/* statusdoc_codage_import est obligatoire si statusdoc_owner != 0 */
if ($data['statusdoc_owner'] != 0 && $data['statusdoc_codage_import'] == "") {
return 0;
}
// préparation de la requête
$key0 = addslashes($data['statut_libelle']);
$key1 = addslashes($data['statusdoc_codage_import']);
$key2 = $data['statusdoc_owner'];
/* vérification que le statut existe */
$query = "SELECT idstatut FROM docs_statut WHERE statusdoc_codage_import='{$key1}' and statusdoc_owner = '{$key2}' LIMIT 1 ";
$result = @mysql_query($query, $dbh);
if (!$result) {
die("can't SELECT docs_statut " . $query);
}
$docs_statut = mysql_fetch_object($result);
/* le statut de doc existe, on retourne l'ID */
if ($docs_statut->idstatut) {
return $docs_statut->idstatut;
}
// id non-récupérée, il faut créer la forme.
/* une petite valeur par défaut */
if ($data['pret_flag'] == "") {
$data['pret_flag'] = 1;
}
$query = "INSERT INTO docs_statut SET ";
$query .= "statut_libelle='" . $key0 . "', ";
$query .= "pret_flag='" . $data['pret_flag'] . "', ";
$query .= "statusdoc_codage_import='" . $key1 . "', ";
$query .= "statusdoc_owner='" . $key2 . "' ";
$result = @mysql_query($query, $dbh);
if (!$result) {
die("can't INSERT into docs_statut " . $query);
}
return mysql_insert_id($dbh);
}
示例5: import
function import($data)
{
// cette méthode prend en entrée un tableau constitué des informations suivantes :
// $data['section_libelle']
// $data['sdoc_codage_import']
// $data['sdoc_owner']
global $dbh;
// check sur le type de la variable passée en paramètre
if (!sizeof($data) || !is_array($data)) {
// si ce n'est pas un tableau ou un tableau vide, on retourne 0
return 0;
}
// check sur les éléments du tableau
$long_maxi = mysql_field_len(mysql_query("SELECT section_libelle FROM docs_section limit 1"), 0);
$data['section_libelle'] = rtrim(substr(preg_replace('/\\[|\\]/', '', rtrim(ltrim($data['section_libelle']))), 0, $long_maxi));
$long_maxi = mysql_field_len(mysql_query("SELECT sdoc_codage_import FROM docs_section limit 1"), 0);
$data['sdoc_codage_import'] = rtrim(substr(preg_replace('/\\[|\\]/', '', rtrim(ltrim($data['sdoc_codage_import']))), 0, $long_maxi));
if ($data['sdoc_owner'] == "") {
$data['sdoc_owner'] = 0;
}
if ($data['section_libelle'] == "") {
return 0;
}
/* sdoc_codage_import est obligatoire si sdoc_owner != 0 */
// if(($data['sdoc_owner']!=0) && ($data['sdoc_codage_import']=="")) return 0;
// préparation de la requête
$key0 = addslashes($data['section_libelle']);
$key1 = addslashes($data['sdoc_codage_import']);
$key2 = $data['sdoc_owner'];
/* vérification que la section existe */
$query = "SELECT idsection FROM docs_section WHERE sdoc_codage_import='{$key1}' and sdoc_owner = '{$key2}' LIMIT 1 ";
$result = @mysql_query($query, $dbh);
if (!$result) {
die("can't SELECT docs_section " . $query);
}
$docs_section = mysql_fetch_object($result);
/* le type de doc existe, on retourne l'ID */
if ($docs_section->idsection) {
return $docs_section->idsection;
}
// id non-récupérée, il faut créer la forme.
$query = "INSERT INTO docs_section SET ";
$query .= "section_libelle='" . $key0 . "', ";
$query .= "sdoc_codage_import='" . $key1 . "', ";
$query .= "sdoc_owner='" . $key2 . "' ";
$result = @mysql_query($query, $dbh);
if (!$result) {
die("can't INSERT into docs_section " . $query);
}
$id_section_cree = mysql_insert_id($dbh);
$query = "insert into docsloc_section (SELECT {$id_section_cree}, idlocation FROM docs_location) ";
$result = @mysql_query($query, $dbh);
return $id_section_cree;
}
示例6: 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;
}
示例7: ep4_zen_field_length
function ep4_zen_field_length($tbl, $fld)
{
global $db;
$project = PROJECT_VERSION_MAJOR . '.' . PROJECT_VERSION_MINOR;
$ep_uses_mysqli = PROJECT_VERSION_MAJOR > '1' || PROJECT_VERSION_MINOR >= '5.3' ? true : false;
$meta = array();
$result = $ep_uses_mysqli ? mysqli_query("SELECT {$fld} FROM {$tbl}") : mysql_query("SELECT {$fld} FROM {$tbl}");
if (!$result) {
echo 'Could not run query: ' . ($ep_uses_mysqli ? mysqli_error($db->link) : mysql_error());
exit;
}
$length = $ep_uses_mysqli ? mysqli_field_len($result, 0) : mysql_field_len($result, 0);
return $length;
}
示例8: getTableFieldHash
function getTableFieldHash($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);
$return[$field_name]['name'] = $field_name;
$return[$field_name]['type'] = mysql_field_type($fields, $i);
$return[$field_name]['length'] = mysql_field_len($fields, $i);
$return[$field_name]['flags'] = explode(" ", mysql_field_flags($fields, $i));
}
return $return;
}
示例9: import
function import($data)
{
// cette méthode prend en entrée un tableau constitué des informations suivantes :
// $data['nom']
// $data['pays']
// $data['diffusion']
global $dbh;
// check sur le type de la variable passée en paramètre
if (!sizeof($data) || !is_array($data)) {
// si ce n'est pas un tableau ou un tableau vide, on retourne 0
return 0;
}
// check sur les éléments du tableau
$long_maxi = mysql_field_len(mysql_query("SELECT orinot_nom FROM origine_notice "), 0);
$data['nom'] = rtrim(substr(preg_replace('/\\[|\\]/', '', rtrim(ltrim($data['nom']))), 0, $long_maxi));
$long_maxi = mysql_field_len(mysql_query("SELECT orinot_pays FROM origine_notice "), 0);
$data['pays'] = rtrim(substr(preg_replace('/\\[|\\]/', '', rtrim(ltrim($data['pays']))), 0, $long_maxi));
if ($data['diffusion'] == "") {
$data['diffusion'] = 1;
}
if ($data['nom'] == "") {
return 0;
}
// préparation de la requête
$key0 = addslashes($data['nom']);
$key1 = addslashes($data['pays']);
$key2 = $data['diffusion'];
/* vérification que le statut existe */
$query = "SELECT orinot_id FROM origine_notice WHERE orinot_nom='{$key0}' and orinot_pays = '{$key1}' LIMIT 1 ";
$result = @mysql_query($query, $dbh);
if (!$result) {
die("can't SELECT origine_notice " . $query);
}
$origine_notice = mysql_fetch_object($result);
/* le statut de doc existe, on retourne l'ID */
if ($origine_notice->orinot_id) {
return $origine_notice->orinot_id;
}
// id non-récupérée, il faut créer la forme.
$query = "INSERT INTO origine_notice SET ";
$query .= "orinot_nom='" . $key0 . "', ";
$query .= "orinot_pays='" . $key1 . "', ";
$query .= "orinot_diffusion='" . $key2 . "' ";
$result = @mysql_query($query, $dbh);
if (!$result) {
die("can't INSERT into origine_notice " . $query);
}
return mysql_insert_id($dbh);
}
示例10: mysql_field_type
case "mysql":
$ret = mysql_field_type($result, $offset);
break;
case "mysqli":
$tmp = mysqli_fetch_field_direct($result, $offset);
$ret = GetCorrectDataTypeMySQLI($tmp->type);
break;
}
return $ret;
}
function yog_mysql_field_len($result, $offset)
{
//Returns the length of the specified field
$ret = 0;
switch (DB_EXTENSION) {
示例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: 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;
}
示例13: mysql_fetch_fields
function mysql_fetch_fields($tb)
{
// LIMIT 1 means to only read rows before row 1 (0-indexed)
$result = mysql_query("SELECT * FROM `{$tb}` LIMIT 0");
$describe = mysql_query("SHOW COLUMNS FROM `{$tb}`");
$num = mysql_num_fields($result);
$output = array();
for ($i = 0; $i < $num; ++$i) {
$field = mysql_fetch_field($result, $i);
// Analyze 'extra' field
$field->auto_increment = strpos(mysql_result($describe, $i, 'Extra'), 'auto_increment') === FALSE ? 0 : 1;
// Create the column_definition
$field->definition = mysql_result($describe, $i, 'Type');
if ($field->not_null && !$field->primary_key) {
$field->definition .= ' NOT NULL';
}
$avmi = mysql_result($describe, $i, 'Default');
if ($avmi != "" && $avmi != "NULL") {
$field->def = $avmi;
} else {
$field->def = false;
}
if ($field->def) {
$field->definition .= " DEFAULT '" . mysql_real_escape_string($field->def) . "'";
}
if ($field->auto_increment) {
$field->definition .= ' AUTO_INCREMENT';
}
if ($key = mysql_result($describe, $i, 'Key')) {
if ($field->primary_key) {
$field->definition .= ' PRIMARY KEY';
} else {
$field->definition .= ' UNIQUE KEY';
}
}
// Create the field length
$field->len = mysql_field_len($result, $i);
// Store the field into the output
$output[$field->name] = $field;
}
return $output;
}
示例14: kdauto
function kdauto($tabel, $inisial)
{
$struktur = mysql_query("SELECT * FROM {$tabel}");
$field = mysql_field_name($struktur, 0);
$panjang = mysql_field_len($struktur, 0);
$qry = mysql_query("SELECT max(" . $field . ") FROM " . $tabel);
$row = mysql_fetch_array($qry);
if ($row[0] == "") {
$angka = 0;
} else {
$angka = substr($row[0], strlen($inisial));
}
$angka++;
$angka = strval($angka);
$tmp = "";
for ($i = 1; $i <= $panjang - strlen($inisial) - strlen($angka); $i++) {
$tmp = $tmp . "0";
}
return $inisial . $tmp . $angka;
}
示例15: ubrows
function ubrows($lc_sql)
{
//$lc_sql為mysql_query()所傳回的變數
$m_field = mysql_num_fields($lc_sql);
//求出查詢的sql命令中共有幾個欄位
$m_table = '<table border="1" align="center" cellspacing="0" ><tr bgcolor="#CCFF66">';
for ($m_l = 0; $m_l < $m_field; $m_l++) {
$m_str = mysql_field_name($lc_sql, $m_l);
$m_table = $m_table . '<td ><span style="font-size:18px"> ' . $m_str . '</span></td>';
}
$m_table = $m_table . '</tr>';
$m_i = 0;
while ($m_record = mysql_fetch_array($lc_sql)) {
$m_color = '#DDFFCC';
if (bcmod($m_i, 2) == 0) {
$m_color = "FFFFFF";
//資料第一筆,就使用白色,第二筆淺綠色,第三筆白色,以此類推
}
$m_table = $m_table . '<tr bgcolor="' . $m_color . '">';
for ($m_k = 0; $m_k < $m_field; $m_k++) {
//$m_field為此sql命令的欄位總數
$m_str = mysql_field_name($lc_sql, $m_k);
$m_type = mysql_field_type($lc_sql, $m_k);
//指定欄位的型態
$m_len = mysql_field_len($lc_sql, $m_k);
//指定欄位的長度
$m_table = $m_table . '<td ><span style="font-size:13px"> ' . $m_record[$m_k] . '</span></td>';
}
$m_table = $m_table . "</tr>";
$m_i = $m_i + 1;
}
$m_table = $m_table . "</table>";
echo "<script>\r\n\t\t\tvar writeWin = null;\r\n\t\t\tfunction writeLeft() { \r\n\r\n\t\t\t\twriteWin =window.open('','aWin','top=50%,left=50%,width=700,status=yes,toolbars=yes,scrollbars=yes,menubar=yes,directories=yes,resizable=yes'); \r\n\t\t\t\tvar ePen ='" . $m_table . "';\r\n\t\t\t\twriteWin.document.open();\r\n\t\t\t\twriteWin.document.write(ePen);\r\n\t\t\t\twriteWin.document.close();\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t</script>";
//window視窗物件
//menubar-->功能表列 [例如] [檔案] [編輯] [檢視] [我的最愛] .. 等 這些按鈕,若沒有設定,則預設為隱藏
//scrollbars-->上下拉式卷軸 若沒有設定則設為只顯示視窗大小的內容
//resizable為是否允許使用者改變視窗大小,若不設定,預設為不允許
echo "<script>writeLeft();</script>";
}