本文整理汇总了PHP中DBLayer::error方法的典型用法代码示例。如果您正苦于以下问题:PHP DBLayer::error方法的具体用法?PHP DBLayer::error怎么用?PHP DBLayer::error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBLayer
的用法示例。
在下文中一共展示了DBLayer::error方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkInputValues
function checkInputValues()
{
global $fdb;
// Check connection
$conn = @mysql_connect($_SESSION['hostname'], $_SESSION['username'], $_SESSION['password']);
if (!$conn) {
myerror('Unable to connect to MySQL server. Please check your settings again.<br><br><a href="?page=settings">Go back to settings</a>');
}
// Check databases
if (!@mysql_select_db($_SESSION['php_db_clean'], $conn)) {
// Fetch database list
$list = '';
$result = @mysql_query('SHOW databases', $conn);
while ($ob = mysql_fetch_row($result)) {
$list .= '   <a href="?page=settings&newdb=' . $ob[0] . '">' . $ob[0] . '</a><br>' . "\n";
}
// Close connection and show message
mysql_close($conn);
myerror('Unable to select database.' . '<br><br>Found these databases:<br><font color="gray">' . $list . '</font>' . '<br><a href="?page=settings">Go back to settings</a>');
}
mysql_close($conn);
// Include FORUM's config file
include './' . $_SESSION['forum'] . '/_config.php';
// Check prefix
$fdb = new DBLayer($_SESSION['hostname'], $_SESSION['username'], $_SESSION['password'], $_SESSION['php_db_clean'], $_SESSION['php_prefix'], false);
$res = $fdb->query('SELECT count(*) FROM ' . $_SESSION['php'] . $tables['Users']);
if (intval($fdb->result($res, 0)) == 0) {
// Select a list of tables
$list = array();
$res = $fdb->query('SHOW TABLES IN ' . $_SESSION['php_db']);
while ($ob = $fdb->fetch_row($res)) {
$list[] = $ob[0];
}
// check list size
sizeof($list) == 0 ? $list[] = 'None' : null;
// Get list of "proabable" prefixes
$prefix_list = '';
$res = $fdb->query('SHOW TABLES FROM ' . $_SESSION['php_db'] . ' LIKE \'%' . $tables['Posts'] . '\'') or myerror('Unable to fetch table list', __FILE__, __LINE__, $fdb->error());
// $res = $fdb->query('SHOW TABLES FROM '.$_SESSION['php_db'].' LIKE \'%'.$tables['Users'].'\'') or myerror('Unable to fetch table list', __FILE__, __LINE__, $fdb->error());
while ($ob = $fdb->fetch_row($res)) {
$prefix = substr($ob[0], 0, strlen($ob[0]) - strlen($tables['Users']));
$prefix_list .= ' <a href="?page=settings&newprefix=' . $prefix . '">' . $prefix . '</a><br>' . "\n";
}
// Print message
$prefix = $_SESSION['php_prefix'] == '' ? 'no' : '\'' . $_SESSION['php_prefix'] . '\'';
myerror('Unable to find ' . $_SESSION['forum'] . ' tables! (using prefix: <i>' . $prefix . '</i>)' . '<br><br>Go back to settings and choose another prefix, or select one of these prefixes:<br><font color="gray">' . $prefix_list . '</font>' . '<br>These are the tables in the selected database:<br><font color="gray"> ' . implode("<br> ", $list) . '</font>' . '<br><br><a href="?page=settings">Go back to settings</a>');
}
}
示例2: generate_password
$tr = array("А" => "A", "Б" => "B", "В" => "V", "Г" => "G", "Д" => "D", "Е" => "E", "Ё" => "E", "Ж" => "ZH", "З" => "Z", "И" => "I", "Й" => "Y", "К" => "K", "Л" => "L", "М" => "M", "Н" => "N", "О" => "O", "П" => "P", "Р" => "R", "С" => "S", "Т" => "T", "У" => "U", "Ф" => "F", "Х" => "H", "Ц" => "TS", "Ч" => "CH", "Ш" => "SH", "Щ" => "SCH", "Ъ" => "", "Ы" => "YI", "Ь" => "", "Э" => "E", "Ю" => "YU", "Я" => "YA", "а" => "a", "б" => "b", "в" => "v", "г" => "g", "д" => "d", "е" => "e", "ё" => "e", "ж" => "zh", "з" => "z", "и" => "i", "й" => "y", "к" => "k", "л" => "l", "м" => "m", "н" => "n", "о" => "o", "п" => "p", "р" => "r", "с" => "s", "т" => "t", "у" => "u", "ф" => "f", "х" => "h", "ц" => "ts", "ч" => "ch", "ш" => "sh", "щ" => "sch", "ъ" => "y", "ы" => "yi", "ь" => "", "э" => "e", "ю" => "yu", "я" => "ya");
return strtr($str, $tr);
}
function generate_password($length)
{
$pass = "";
$arr = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'v', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'U', 'V', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9');
for ($i = 0; $i < $length; $i++) {
$index = rand(0, count($arr) - 1);
// Случайный индекс массива
$pass .= $arr[$index];
}
return $pass;
}
$users = getUsers(true);
foreach ($users as $id => $user) {
$users[$id]["permissions"] = 33;
$users[$id]["login"] = mb_strtolower(translit(mb_substr($user["firstname"], 0, 1, "UTF-8") . $user["lastname"]));
$users[$id]["login_ae"] = mb_strtoupper(mb_substr($user["firstname"], 0, 1, "UTF-8") . mb_substr($user["middlename"], 0, 1, "UTF-8") . $user["lastname"], "UTF-8");
$users[$id]["email"] = $users[$id]["login"] . "@megacorp.com";
$users[$id]["password"] = generate_password(8);
$query = "UPDATE users SET\r\n `login`='" . $users[$id]["login"] . "',\r\n `login_ae`='" . $users[$id]["login_ae"] . "',\r\n `pass`='" . $users[$id]["password"] . "',\r\n `email`='" . $users[$id]["email"] . "'\r\n WHERE `uid`={$id}";
// echo "\n\n";
$query_upd = $db->query($query);
if ($query_upd) {
echo 1;
}
}
//print_r($users);
print_r($db->error());
示例3: switch
// Create all tables
switch ($db_type) {
case 'mysql':
case 'mysqli':
$sql = 'CREATE TABLE ' . $db_prefix . "bans (\n\t\t\t\t\tid INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t\tusername VARCHAR(200),\n\t\t\t\t\tip VARCHAR(255),\n\t\t\t\t\temail VARCHAR(50),\n\t\t\t\t\tmessage VARCHAR(255),\n\t\t\t\t\texpire INT(10) UNSIGNED,\n\t\t\t\t\tPRIMARY KEY (id)\n\t\t\t\t\t) TYPE=MyISAM;";
break;
case 'pgsql':
$db->start_transaction();
$sql = 'CREATE TABLE ' . $db_prefix . "bans (\n\t\t\t\t\tid SERIAL,\n\t\t\t\t\tusername VARCHAR(200),\n\t\t\t\t\tip VARCHAR(255),\n\t\t\t\t\temail VARCHAR(50),\n\t\t\t\t\tmessage VARCHAR(255),\n\t\t\t\t\texpire INT,\n\t\t\t\t\tPRIMARY KEY (id)\n\t\t\t\t\t)";
break;
case 'sqlite':
$db->start_transaction();
$sql = 'CREATE TABLE ' . $db_prefix . "bans (\n\t\t\t\t\tid INTEGER NOT NULL,\n\t\t\t\t\tusername VARCHAR(200),\n\t\t\t\t\tip VARCHAR(255),\n\t\t\t\t\temail VARCHAR(50),\n\t\t\t\t\tmessage VARCHAR(255),\n\t\t\t\t\texpire INTEGER,\n\t\t\t\t\tPRIMARY KEY (id)\n\t\t\t\t\t)";
break;
}
$db->query($sql) or error('Unable to create table ' . $db_prefix . 'bans. Please check your settings and try again.', __FILE__, __LINE__, $db->error());
switch ($db_type) {
case 'mysql':
case 'mysqli':
$sql = 'CREATE TABLE ' . $db_prefix . "categories (\n\t\t\t\t\tid INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\n\t\t\t\t\tcat_name VARCHAR(80) NOT NULL DEFAULT 'New Category',\n\t\t\t\t\tdisp_position INT(10) NOT NULL DEFAULT 0,\n\t\t\t\t\tPRIMARY KEY (id)\n\t\t\t\t\t) TYPE=MyISAM;";
break;
case 'pgsql':
$sql = 'CREATE TABLE ' . $db_prefix . "categories (\n\t\t\t\t\tid SERIAL,\n\t\t\t\t\tcat_name VARCHAR(80) NOT NULL DEFAULT 'New Category',\n\t\t\t\t\tdisp_position INT NOT NULL DEFAULT 0,\n\t\t\t\t\tPRIMARY KEY (id)\n\t\t\t\t\t)";
break;
case 'sqlite':
$sql = 'CREATE TABLE ' . $db_prefix . "categories (\n\t\t\t\t\tid INTEGER NOT NULL,\n\t\t\t\t\tcat_name VARCHAR(80) NOT NULL DEFAULT 'New Category',\n\t\t\t\t\tdisp_position INTEGER NOT NULL DEFAULT 0,\n\t\t\t\t\tPRIMARY KEY (id)\n\t\t\t\t\t)";
break;
}
$db->query($sql) or error('Unable to create table ' . $db_prefix . 'categories. Please check your settings and try again.', __FILE__, __LINE__, $db->error());
switch ($db_type) {
case 'mysql':
示例4: list
// Check if InnoDB is available
if ($db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb') {
$result = $db->query('SHOW VARIABLES LIKE \'have_innodb\'');
list(, $result) = $db->fetch_row($result);
if (strtoupper($result) != 'YES') {
error($lang_install['InnoDB off']);
}
}
// Start a transaction
$db->start_transaction();
// Create all tables
$schema = array('FIELDS' => array('id' => array('datatype' => 'SERIAL', 'allow_null' => false), 'username' => array('datatype' => 'VARCHAR(200)', 'allow_null' => true), 'ip' => array('datatype' => 'VARCHAR(255)', 'allow_null' => true), 'email' => array('datatype' => 'VARCHAR(80)', 'allow_null' => true), 'message' => array('datatype' => 'VARCHAR(255)', 'allow_null' => true), 'expire' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => true), 'ban_creator' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0')), 'PRIMARY KEY' => array('id'), 'INDEXES' => array('username_idx' => array('username')));
if ($db_type == 'mysql' || $db_type == 'mysqli' || $db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb') {
$schema['INDEXES']['username_idx'] = array('username(25)');
}
$db->create_table('bans', $schema) or error('Unable to create bans table', __FILE__, __LINE__, $db->error());
$schema = array('FIELDS' => array('id' => array('datatype' => 'SERIAL', 'allow_null' => false), 'cat_name' => array('datatype' => 'VARCHAR(80)', 'allow_null' => false, 'default' => '\'New Category\''), 'disp_position' => array('datatype' => 'INT(10)', 'allow_null' => false, 'default' => '0')), 'PRIMARY KEY' => array('id'));
$db->create_table('categories', $schema) or error('Unable to create categories table', __FILE__, __LINE__, $db->error());
$schema = array('FIELDS' => array('id' => array('datatype' => 'SERIAL', 'allow_null' => false), 'search_for' => array('datatype' => 'VARCHAR(60)', 'allow_null' => false, 'default' => '\'\''), 'replace_with' => array('datatype' => 'VARCHAR(60)', 'allow_null' => false, 'default' => '\'\'')), 'PRIMARY KEY' => array('id'));
$db->create_table('censoring', $schema) or error('Unable to create censoring table', __FILE__, __LINE__, $db->error());
$schema = array('FIELDS' => array('conf_name' => array('datatype' => 'VARCHAR(255)', 'allow_null' => false, 'default' => '\'\''), 'conf_value' => array('datatype' => 'TEXT', 'allow_null' => true)), 'PRIMARY KEY' => array('conf_name'));
$db->create_table('config', $schema) or error('Unable to create config table', __FILE__, __LINE__, $db->error());
$schema = array('FIELDS' => array('group_id' => array('datatype' => 'INT(10)', 'allow_null' => false, 'default' => '0'), 'forum_id' => array('datatype' => 'INT(10)', 'allow_null' => false, 'default' => '0'), 'read_forum' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'post_replies' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'post_topics' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1')), 'PRIMARY KEY' => array('group_id', 'forum_id'));
$db->create_table('forum_perms', $schema) or error('Unable to create forum_perms table', __FILE__, __LINE__, $db->error());
$schema = array('FIELDS' => array('id' => array('datatype' => 'SERIAL', 'allow_null' => false), 'forum_name' => array('datatype' => 'VARCHAR(80)', 'allow_null' => false, 'default' => '\'New forum\''), 'forum_desc' => array('datatype' => 'TEXT', 'allow_null' => true), 'redirect_url' => array('datatype' => 'VARCHAR(100)', 'allow_null' => true), 'moderators' => array('datatype' => 'TEXT', 'allow_null' => true), 'num_topics' => array('datatype' => 'MEDIUMINT(8) UNSIGNED', 'allow_null' => false, 'default' => '0'), 'num_posts' => array('datatype' => 'MEDIUMINT(8) UNSIGNED', 'allow_null' => false, 'default' => '0'), 'last_post' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => true), 'last_post_id' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => true), 'last_poster' => array('datatype' => 'VARCHAR(200)', 'allow_null' => true), 'sort_by' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0'), 'disp_position' => array('datatype' => 'INT(10)', 'allow_null' => false, 'default' => '0'), 'cat_id' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0')), 'PRIMARY KEY' => array('id'));
$db->create_table('forums', $schema) or error('Unable to create forums table', __FILE__, __LINE__, $db->error());
$schema = array('FIELDS' => array('g_id' => array('datatype' => 'SERIAL', 'allow_null' => false), 'g_title' => array('datatype' => 'VARCHAR(50)', 'allow_null' => false, 'default' => '\'\''), 'g_user_title' => array('datatype' => 'VARCHAR(50)', 'allow_null' => true), 'g_promote_min_posts' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0'), 'g_promote_next_group' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0'), 'g_moderator' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0'), 'g_mod_edit_users' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0'), 'g_mod_rename_users' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0'), 'g_mod_change_passwords' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0'), 'g_mod_ban_users' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0'), 'g_mod_promote_users' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0'), 'g_read_board' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_view_users' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_post_replies' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_post_topics' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_edit_posts' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_delete_posts' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_delete_topics' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_post_links' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_set_title' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_search' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_search_users' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_send_email' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '1'), 'g_post_flood' => array('datatype' => 'SMALLINT(6)', 'allow_null' => false, 'default' => '30'), 'g_search_flood' => array('datatype' => 'SMALLINT(6)', 'allow_null' => false, 'default' => '30'), 'g_email_flood' => array('datatype' => 'SMALLINT(6)', 'allow_null' => false, 'default' => '60'), 'g_report_flood' => array('datatype' => 'SMALLINT(6)', 'allow_null' => false, 'default' => '60')), 'PRIMARY KEY' => array('g_id'));
$db->create_table('groups', $schema) or error('Unable to create groups table', __FILE__, __LINE__, $db->error());
$schema = array('FIELDS' => array('user_id' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '1'), 'ident' => array('datatype' => 'VARCHAR(200)', 'allow_null' => false, 'default' => '\'\''), 'logged' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => false, 'default' => '0'), 'idle' => array('datatype' => 'TINYINT(1)', 'allow_null' => false, 'default' => '0'), 'last_post' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => true), 'last_search' => array('datatype' => 'INT(10) UNSIGNED', 'allow_null' => true)), 'UNIQUE KEYS' => array('user_id_ident_idx' => array('user_id', 'ident')), 'INDEXES' => array('ident_idx' => array('ident'), 'logged_idx' => array('logged')));
if ($db_type == 'mysql' || $db_type == 'mysqli' || $db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb') {
$schema['UNIQUE KEYS']['user_id_ident_idx'] = array('user_id', 'ident(25)');
示例5: header
// Load forum specific settings
if (file_exists('./' . $_SESSION['forum'] . '/_settings.php')) {
include './' . $_SESSION['forum'] . '/_settings.php';
}
// Limit
$_SESSION['limit'] = 100;
// Load all forum common start file
require 'start.php';
// Redirect to first forum convert file
header('Location: index.php?step=' . $parts[0]);
}
// Connect to database (might be the same as fluxbb uses)
if (isset($page) && $page != 'settings' || isset($step)) {
$fdb = new DBLayer($_SESSION['hostname'], $_SESSION['username'], $_SESSION['password'], $_SESSION['php_db'], $_SESSION['php_prefix'], false);
if ($_SESSION['old_charset'] != '' && $_SESSION['old_charset'] != 'UTF-8') {
$fdb->query('SET NAMES \'latin1\'') or myerror("Unable to set names", __FILE__, __LINE__, $fdb->error());
}
}
// Header
require 'header.php';
?>
<table class="punmain" cellspacing="1" cellpadding="4">
<?php
// Check for the lock-file
if (file_exists('LOCKED') && (!isset($page) || $page != 'done')) {
conv_message('This converter is locked to prevent other users to alter the databases.<br><br>Please remove the file \'LOCKED\' in the converter directory and reload this page to run the converter again. If you are done with the converter, it\'s okay to remove the entire directory instead.');
exit;
}
// Load the proper page
示例6: DBLayer
<?php
require "subs.php";
require_once "conf.inc.php";
require_once "lib/dblayer.php";
$btn_home = "<a class='button' href='./'><<</a>";
$db = new DBLayer($CNF["db_host"], $CNF["db_user"], $CNF["db_pass"], $CNF["db_name"]);
$db->query("SET NAMES utf8");
$q = "SELECT\n u.`uid`,\n u.`modiff`,\n DATE_FORMAT(u.`modiff`,'%d.%m.%Y %H:%i:%s') AS `modiff_fmt`,\n (SELECT CONCAT(`lastname`,' ',`firstname`) FROM users WHERE `uid`=u.`modiff_uid`) AS `modiff_uid`,\n u.`status_id`,\n u.`lastname`,\n u.`firstname`,\n u.`middlename`,\n u.`login`,\n u.`pass`\n FROM users AS u ORDER BY `uid` DESC LIMIT 5";
if ($qry = $db->query($q)) {
eval(tmplt_gen("stat/forms/begin.form"));
eval(tmplt_gen("users/forms/filter.form"));
while ($res = $db->fetch_assoc($qry)) {
$page .= table_users($res);
}
$page .= "</table>";
$page .= "<div class='table-footer'><span class='statusbar'> </span>";
} else {
echo 'error';
}
//print_r($res);
echo $page;
$db_err = $db->error();
$db->close();
if ($db_err["error_no"] != null) {
print_r($db_err);
}
// DB-errors