本文整理汇总了PHP中mysql_field_len函数的典型用法代码示例。如果您正苦于以下问题:PHP mysql_field_len函数的具体用法?PHP mysql_field_len怎么用?PHP mysql_field_len使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysql_field_len函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:jaksmid,项目名称:website,代码行数:39,代码来源:mysql_result.php
示例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;
}
开发者ID:juliogallardo1326,项目名称:proc,代码行数:31,代码来源:____updateAccess.old.php
示例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;
}
开发者ID:ehrlichandreas,项目名称:ehrlichandreas1-pdo,代码行数:31,代码来源:Statement.php
示例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);
}
开发者ID:bouchra012,项目名称:PMB,代码行数:59,代码来源:docs_statut.class.php
示例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;
}
开发者ID:bouchra012,项目名称:PMB,代码行数:54,代码来源:docs_section.class.php
示例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;
}
开发者ID:BackupTheBerlios,项目名称:sitexs,代码行数:12,代码来源:mysql.class.php
示例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;
}
开发者ID:xiaoguizhidao,项目名称:EasyPopulate-4.0,代码行数:14,代码来源:easypopulate_4_functions.php
示例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;
}
开发者ID:iwater,项目名称:kissphp,代码行数:14,代码来源:PDO_MySqlCommand.php
示例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);
}
开发者ID:bouchra012,项目名称:PMB,代码行数:49,代码来源:origine_notice.class.php
示例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) {
开发者ID:shainmcalindon,项目名称:boothsgardenstudios,代码行数:15,代码来源:andrews-tunnel.php
示例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;
}
开发者ID:reekoheek,项目名称:php-fw,代码行数:16,代码来源:MysqlDriver.php
示例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;
}
开发者ID:abhinay100,项目名称:clockingit,代码行数:19,代码来源:SQL_Export.php
示例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;
}
开发者ID:sembrono,项目名称:1,代码行数:42,代码来源:table.php
示例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;
}
开发者ID:FaddliLWibowo,项目名称:SistemPakar,代码行数:20,代码来源:inc.kodeauto.php
示例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>";
}
开发者ID:a5216652166,项目名称:android-novel-reader,代码行数:39,代码来源:code.fun.php
示例16: buatKode
function buatKode($tabel, $inisial)
{
$struktur = mysql_query("SELECT * FROM {$tabel}");
$field = mysql_field_name($struktur, 0);
$panjang = mysql_field_len($struktur, 0);
// membaca panjang kolom
$hasil = mysql_fetch_field($struktur, 0);
//$panjang = $hasil->max_length;
$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;
}
开发者ID:gumilarb,项目名称:presentasi,代码行数:23,代码来源:inc.library.php
示例17: metadata
function metadata($table = "", $full = false)
{
$count = 0;
$id = 0;
$res = array();
/*
* Due to compatibility problems with Table we changed the behavior
* of metadata();
* depending on $full, metadata returns the following values:
*
* - full is false (default):
* $result[]:
* [0]["table"] table name
* [0]["name"] field name
* [0]["type"] field type
* [0]["len"] field length
* [0]["flags"] field flags
*
* - full is true
* $result[]:
* ["num_fields"] number of metadata records
* [0]["table"] table name
* [0]["name"] field name
* [0]["type"] field type
* [0]["len"] field length
* [0]["flags"] field flags
* ["meta"][field name] index of field named "field name"
* This last one could be used if you have a field name, but no index.
* Test: if (isset($result['meta']['myfield'])) { ...
*/
// if no $table specified, assume that we are working with a query
// result
if ($table) {
$this->connect();
$id = mysql_list_fields($this->Database, $table);
if (!$id) {
$this->halt("Metadata query failed.");
return false;
}
} else {
$id = $this->Query_ID;
if (!$id) {
$this->halt("No query specified.");
return false;
}
}
$count = mysql_num_fields($id);
// made this IF due to performance (one if is faster than $count if's)
if (!$full) {
for ($i = 0; $i < $count; $i++) {
$res[$i]["table"] = mysql_field_table($id, $i);
$res[$i]["name"] = mysql_field_name($id, $i);
$res[$i]["type"] = mysql_field_type($id, $i);
$res[$i]["len"] = mysql_field_len($id, $i);
$res[$i]["flags"] = mysql_field_flags($id, $i);
}
} else {
// full
$res["num_fields"] = $count;
for ($i = 0; $i < $count; $i++) {
$res[$i]["table"] = mysql_field_table($id, $i);
$res[$i]["name"] = mysql_field_name($id, $i);
$res[$i]["type"] = mysql_field_type($id, $i);
$res[$i]["len"] = mysql_field_len($id, $i);
$res[$i]["flags"] = mysql_field_flags($id, $i);
$res["meta"][$res[$i]["name"]] = $i;
}
}
// free the result only if we were called on a table
if ($table) {
#mysql_free_result($id);
$this->free();
}
return $res;
}
开发者ID:aydancoskun,项目名称:octobercms,代码行数:75,代码来源:Class_DB.inc.php
示例18: execute
public function execute($sql)
{
// hide errors
$ini_err = ini_get('display_errors');
ini_set('display_errors', 0);
$res = false;
$this->res_errMsg = null;
// --- process sql
if ($this->dbType == 'postgres') {
$this->res_data = pg_query($this->dbConn, $sql);
if (!$this->res_data) {
$this->res_errMsg = pg_last_error($this->dbConn);
} else {
$this->res_errMsg = pg_result_error($this->res_data);
$this->res_affectedRows = pg_affected_rows($this->res_data);
$this->res_rowCount = pg_num_rows($this->res_data);
$this->res_fieldCount = pg_num_fields($this->res_data);
$res = new dbRecordSet($this->dbType, $this->res_data, $this->res_rowCount, $this->res_fieldCount);
// -- parse field names
for ($i = 0; $i < $this->res_fieldCount; $i++) {
$this->res_fields[$i] = pg_field_name($this->res_data, $i);
$this->res_fieldsInfo[$i] = array();
$this->res_fieldsInfo[$i]['type'] = pg_field_type($this->res_data, $i);
$this->res_fieldsInfo[$i]['len'] = pg_field_size($this->res_data, $i);
$this->res_fieldsInfo[$i]['is_null'] = pg_field_is_null($this->res_data, $i);
$this->res_fieldsInfo[$i]['prt_len'] = pg_field_prtlen($this->res_data, $i);
}
}
// log error
if ($this->res_errMsg != '') {
// put here code to log error
}
}
// --- mysql
if ($this->dbType == 'mysql') {
$this->res_data = mysql_query($sql, $this->dbConn);
if (!$this->res_data) {
$this->res_errMsg = mysql_error($this->dbConn);
} else {
@($this->res_errMsg = mysql_error($this->res_data));
@($this->res_affectedRows = mysql_affected_rows($this->res_data));
@($this->res_rowCount = mysql_num_rows($this->res_data));
@($this->res_fieldCount = mysql_num_fields($this->res_data));
@($res = new dbRecordSet($this->dbType, $this->res_data, $this->res_rowCount, $this->res_fieldCount));
// -- parse field names
for ($i = 0; $i < $this->res_fieldCount; $i++) {
$this->res_fields[$i] = mysql_field_name($this->res_data, $i);
$this->res_fieldsInfo[$i] = array();
$this->res_fieldsInfo[$i]['type'] = mysql_field_type($this->res_data, $i);
$this->res_fieldsInfo[$i]['len'] = mysql_field_len($this->res_data, $i);
$this->res_fieldsInfo[$i]['flags'] = mysql_field_flags($this->res_data, $i);
}
}
// log error
if ($this->res_errMsg != '') {
// put here code to log error
}
}
$this->res_sql = $sql;
// show debug info if on
if ($this->debug == true) {
print "<pre>" . $sql . "<hr>";
if ($this->res_errMsg != '') {
print "<span style='color: red'>" . $this->res_errMsg . "</span><hr>";
}
print "</pre>";
}
// restore errors
ini_set('display_errors', $ini_err);
return $res;
}
开发者ID:LeisureLeo,项目名称:w2ui,代码行数:71,代码来源:w2db.php
示例19: execute
public function execute($sql)
{
global $sys_dbPrefix;
global $ses_userid;
// hide errors
$ini_err = ini_get('display_errors');
ini_set('display_errors', 0);
$res = false;
// --- process sql
if ($this->dbType == 'postgres') {
$this->res_data = pg_query($this->dbConn, $sql);
if (!$this->res_data) {
$this->res_errMsg = pg_last_error($this->dbConn);
} else {
$this->res_errMsg = pg_result_error($this->res_data);
$this->res_affectedRows = pg_affected_rows($this->res_data);
$this->res_rowCount = pg_num_rows($this->res_data);
$this->res_fieldCount = pg_num_fields($this->res_data);
$res = new phpRecordSet($this->dbType, $this->res_data, $this->res_rowCount, $this->res_fieldCount);
// -- parse field names
for ($i = 0; $i < $this->res_fieldCount; $i++) {
$this->res_fields[$i] = pg_field_name($this->res_data, $i);
$this->res_fieldsInfo[$i] = array();
$this->res_fieldsInfo[$i]['type'] = pg_field_type($this->res_data, $i);
$this->res_fieldsInfo[$i]['len'] = pg_field_size($this->res_data, $i);
$this->res_fieldsInfo[$i]['is_null'] = pg_field_is_null($this->res_data, $i);
$this->res_fieldsInfo[$i]['prt_len'] = pg_field_prtlen($this->res_data, $i);
}
}
// log error
if ($this->res_errMsg != '') {
$userid = $ses_userid != null ? $ses_userid : 'null';
$ssql = "INSERT INTO " . $sys_dbPrefix . "log_error(domain, url, userid, sql, error)\n\t\t\t\t\t\t VALUES('" . $_SERVER["HTTP_HOST"] . "', '" . pg_escape_string($_SERVER["REQUEST_URI"]) . "', {$userid}, \n\t\t\t\t\t\t\t'" . pg_escape_string($sql) . "', '" . pg_escape_string($this->res_errMsg) . "');";
pg_query($this->dbConn, $ssql);
}
}
// --- mysql
if ($this->dbType == 'mysql') {
$this->res_data = mysql_query($sql, $this->dbConn);
if (!$this->res_data) {
$this->res_errMsg = mysql_error($this->dbConn);
} else {
$this->res_errMsg = mysql_error($this->res_data);
$this->res_affectedRows = mysql_affected_rows($this->res_data);
$this->res_rowCount = mysql_num_rows($this->res_data);
$this->res_fieldCount = mysql_num_fields($this->res_data);
$res = new phpRecordSet($this->dbType, $this->res_data, $this->res_rowCount, $this->res_fieldCount);
// -- parse field names
for ($i = 0; $i < $this->res_fieldCount; $i++) {
$this->res_fields[$i] = mysql_field_name($this->res_data, $i);
$this->res_fieldsInfo[$i] = array();
$this->res_fieldsInfo[$i]['type'] = mysql_field_type($this->res_data, $i);
$this->res_fieldsInfo[$i]['len'] = mysql_field_len($this->res_data, $i);
$this->res_fieldsInfo[$i]['flags'] = mysql_field_flags($this->res_data, $i);
}
}
// log error
if ($this->res_errMsg != '') {
$userid = $ses_userid != null ? $ses_userid : 'null';
$ssql = "INSERT INTO " . $sys_dbPrefix . "log_error(domain, url, userid, sql, error)\n\t\t\t\t\t\t VALUES('" . $_SERVER["HTTP_HOST"] . "', '" . mysql_escape_string($_SERVER["REQUEST_URI"]) . "', {$userid}, \n\t\t\t\t\t\t\t'" . mysql_escape_string($sql) . "', '" . mysql_escape_string($this->res_errMsg) . "');";
mysql_query($this->dbConn, $ssql);
}
}
// show debug info if on
if ($this->debug == true) {
print "<pre>" . $sql . "<hr>";
if ($this->res_errMsg != '') {
print "<span style='color: red'>" . $this->res_errMsg . "</span><hr>";
}
print "</pre>";
}
// restore errors
ini_set('display_errors', $ini_err);
return $res;
}
开发者ID:visapi,项目名称:Web-2.0-File-Manager,代码行数:75,代码来源:phpDB.php
示例20: MySQL_Field_Len_Test
/**
* Test mysql_field_len
*
* @return boolean
*/
public function MySQL_Field_Len_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
$length1 = mysql_field_len($query1, 0);
$length2 = $this->_object->mysql_field_len($query2, 0);
return $length1 === $length2;
}
开发者ID:ReKungPaw,项目名称:mysql,代码行数:19,代码来源:MySQL_Test.php
注:本文中的mysql_field_len函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论