本文整理汇总了PHP中get_tables函数的典型用法代码示例。如果您正苦于以下问题:PHP get_tables函数的具体用法?PHP get_tables怎么用?PHP get_tables使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_tables函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: startProcess
function startProcess($db)
{
$businessComfirmUrl = Yii::app()->params['orderUrl'] . "update/order/business-confirm-order";
$time = time();
$formatTime = date('Y-m-d H:i:s', $time);
try {
//查找订单
$payTime = $time - 1800;
$sql = "SELECT b.business_id,o.order_sn from " . get_tables('business_info') . " as b left join " . get_tables('order_info') . " as o on b.business_id=o.business_id WHERE b.express_type in (2, 11, 12) and o.order_status=1 and o.express_type > 0 and o.pay_time <= " . $payTime . " LIMIT 100";
$data = $db->createCommand($sql)->queryAll();
if (!empty($data)) {
foreach ($data as $k => $v) {
$post = ['business_id' => $v['business_id'], 'order_sn' => $v['order_sn'], 'user_id' => 1, 'user_name' => 'jiaoben', 'source' => 'autoStockUp'];
$return = curlPost($businessComfirmUrl, $post);
if ($return['code'] != 0) {
addLog("data:" . json_encode($return, JSON_UNESCAPED_UNICODE) . '|time:' . $formatTime);
echo $v['order_sn'] . ":fail" . "\r\n";
} else {
echo $v['order_sn'] . ":success" . "\r\n";
}
}
echo "data update:" . count($data) . "\r\n";
} else {
echo "no data \r\n";
}
echo 'finish';
} catch (Exception $e) {
$msg = "filename:autoStockUp|functionname:start_process|error:" . $e->getMessage() . "|time:" . $formatTime;
echo $msg . "\r\n";
addLog($msg);
}
}
示例2: del_tables
function del_tables($prefix)
{
$tables = get_tables($prefix);
$query = 'drop table ' . $tables[0];
for ($i = 0; $i < count($tables); $i++) {
$query .= "," . $tables[$i];
}
$query .= ";";
mysql_query($query);
}
示例3: drop_tables
function drop_tables($prefix) {
$tables = get_tables($prefix);
$query = 'drop table `' . $tables[0] . "`";
for ($i=1; $i < count($tables); $i++)
$query .= ", `" . $tables[$i] . "`";
$query .= ";";
print $query;
mysql_query($query);
}
示例4: unset
<?php
// Purpose working with data (import/export, type in, ...)
// Author Lutz Brueckner <irie@gmx.de>
// Copyright (c) 2000-2006 by Lutz Brueckner,
// published under the terms of the GNU General Public Licence v.2,
// see file LICENCE for details
require './inc/script_start.inc.php';
require './inc/foreign_keys.inc.php';
require './inc/DataForm.php';
//
// setup $s_tables[] and $s_fields[] if necessary
//
if ($s_connected && $s_tables_valid == FALSE) {
include_once './inc/get_tables.inc.php';
if (get_tables($dbhandle)) {
$s_tables_valid = TRUE;
}
}
require './inc/handle_watchtable.inc.php';
//
// handle foreign key lookup configuration
//
$customize_changed = FALSE;
if (isset($_POST['dt_column_config_save'])) {
$column = get_request_data('dt_column_config_column');
$table = get_request_data('dt_column_config_table');
$fk_column = get_request_data('dt_column_config_fk_column');
if ($fk_column == '') {
unset($s_cust['fk_lookups'][$table][$column]);
if (empty($s_cust['fk_lookups'][$table])) {
示例5: export_db
function export_db($is_backup = false)
{
global $db, $db_host, $db_user, $db_pass, $db_name, $db_port;
$stime = microtime(true);
if ($is_backup) {
$output_file = str_replace('\\', '/', getcwd()) . "/backup/" . date("Y-m-d_H-i-s") . ".php";
} else {
$changes = get_changes();
$i = 0;
while (true) {
$i += 1;
$file_name = date("Y-m-d") . "-" . sprintf("%02d", $i);
$ver = (int) str_replace('-', '', $file_name);
if (array_key_exists($ver, $changes) == false) {
break;
}
}
$output_file = str_replace('\\', '/', getcwd()) . "/changes/" . $file_name . ".dump.php";
}
$file = fopen($output_file, 'c');
$tables = get_tables($db_host, $db_user, $db_pass, $db_name, $db_port);
$max_length = get_max_length($tables);
fwrite($file, "<?php\n\n");
fwrite($file, "echo \"\\n\\n\";\n");
fwrite($file, "\n execute(\"\n /*!40101 SET NAMES utf8 */;\n\n /*!40101 SET SQL_MODE=''*/;\n\n /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;\n /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;\n /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;\n /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;\n \");\n ");
foreach ($tables as $table) {
if ($table == "db_version") {
continue;
}
if ($is_backup) {
echo "backup ";
} else {
echo "dump ";
}
echo $table . " ";
$dots = generate_char($max_length, strlen($table), '.');
echo $dots . "......... ";
$sql = get_create_table_sql($db, $table);
fwrite($file, 'if ($db_version == 0)' . "\n{\n");
fwrite($file, " echo \" " . $table . " " . $dots . "......... \";\n\n");
fwrite($file, " execute(\"\n");
fwrite($file, $sql);
fwrite($file, "\n\");\n\n");
fwrite($file, " echo \"[created]\\n\"; \n");
fwrite($file, "}\n\n");
if ($is_backup == false && strpos($table, "player") === 0) {
echo "[ignore]\n";
continue;
}
$fields = get_table_fields($db, $table);
$sql = get_insert_into_sql($db, $table, $fields);
fwrite($file, "echo \" " . $table . " " . $dots . "......... \";\n\n");
fwrite($file, "execute(\"DELETE FROM `" . $table . "`\");\n\n");
if ($sql != "") {
fwrite($file, "execute(\"\n");
fwrite($file, $sql);
fwrite($file, "\");\n\n");
}
fwrite($file, "echo \"[loaded]\\n\"; \n");
fwrite($file, "\n");
echo "[done]\n";
}
fwrite($file, "\n execute(\"\n /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;\n /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;\n /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;\n /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;\n \");\n ");
fwrite($file, "echo \"\\n\";\n");
fwrite($file, "?>\n");
fclose($file);
if ($is_backup == false) {
$sql = "UPDATE `db_version` SET `version` = " . $ver . ", `change_time` = UNIX_TIMESTAMP()";
if ($db->query($sql) === FALSE) {
die("can't update db_version");
}
}
$etime = microtime(true);
echo "\ndatabase ";
if ($is_backup) {
echo "backup ";
} else {
echo "dump ";
}
echo "complete in " . round($etime - $stime, 2) . "s\n";
}
示例6: connect_check_db
/**
* Used to test whether we are able to connect to the database the user has specified
* and identify any problems (eg there are already tables with the names we want to use
* @param array $dbms should be of the format of an element of the array returned by {@link get_available_dbms get_available_dbms()} necessary extensions should be loaded already
*/
function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix, $dbhost, $dbuser, $dbpasswd, $dbname, $dbport, $prefix_may_exist = false, $load_dbal = true, $unicode_check = true)
{
global $config, $lang;
$dbms = $dbms_details['DRIVER'];
if ($load_dbal) {
// Include the DB layer
include $phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx;
}
// Instantiate it and set return on error true
$sql_db = 'dbal_' . $dbms;
$db = new $sql_db();
$db->sql_return_on_error(true);
// Check that we actually have a database name before going any further.....
if ($dbms_details['DRIVER'] != 'sqlite' && $dbms_details['DRIVER'] != 'oracle' && $dbname === '') {
$error[] = $lang['INST_ERR_DB_NO_NAME'];
return false;
}
// Make sure we don't have a daft user who thinks having the SQLite database in the forum directory is a good idea
if ($dbms_details['DRIVER'] == 'sqlite' && stripos(phpbb_realpath($dbhost), phpbb_realpath('../')) === 0) {
$error[] = $lang['INST_ERR_DB_FORUM_PATH'];
return false;
}
// Check the prefix length to ensure that index names are not too long and does not contain invalid characters
switch ($dbms_details['DRIVER']) {
case 'mysql':
case 'mysqli':
if (strspn($table_prefix, '-./\\') !== 0) {
$error[] = $lang['INST_ERR_PREFIX_INVALID'];
return false;
}
break;
}
if (strlen($table_prefix) > $prefix_length) {
$error[] = sprintf($lang['INST_ERR_PREFIX_TOO_LONG'], $prefix_length);
return false;
}
// Try and connect ...
if (is_array($db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true))) {
$db_error = $db->sql_error();
$error[] = $lang['INST_ERR_DB_CONNECT'] . '<br />' . ($db_error['message'] ? $db_error['message'] : $lang['INST_ERR_DB_NO_ERROR']);
} else {
// Likely matches for an existing phpBB installation
if (!$prefix_may_exist) {
$temp_prefix = strtolower($table_prefix);
$table_ary = array($temp_prefix . 'attachments', $temp_prefix . 'config', $temp_prefix . 'sessions', $temp_prefix . 'topics', $temp_prefix . 'users');
$tables = get_tables($db);
$tables = array_map('strtolower', $tables);
$table_intersect = array_intersect($tables, $table_ary);
if (sizeof($table_intersect)) {
$error[] = $lang['INST_ERR_PREFIX'];
}
}
// Make sure that the user has selected a sensible DBAL for the DBMS actually installed
switch ($dbms_details['DRIVER']) {
case 'mysqli':
if (version_compare(mysqli_get_server_info($db->db_connect_id), '4.1.3', '<')) {
$error[] = $lang['INST_ERR_DB_NO_MYSQLI'];
}
break;
}
}
if ($error_connect && (!isset($error) || !sizeof($error))) {
return true;
}
return false;
}
示例7: make_db_connections
<link rel="stylesheet" type="text/css" href="../css/body.css" />
<style>
body {font-size:80%; margin:5px;}
h1 {font-size:140%}
table {margin-left:40px; border-collapse:collapse}
td {border:1px solid #C0C0C0; padding:2px}
.grey {background-color:#EAEAEA; font-weight:bold}
.nonexist {background-color:#FFC0C0}
.dkred {background-color:#C00000; color:white; font-weight:bold}
.err {color:red; font-weight:bold}
</style>
</head>
<body>
<?php
if (isset($_POST['submit'])) {
make_db_connections();
$table_list = get_tables($_POST['master_dbname'], $master_mysqli);
foreach ($table_list as $table) {
echo "<h1>{$table}</h1>\n";
compare_indexes($_POST['master_dbname'], $_POST['test_dbname'], $table, $master_mysqli, $test_mysqli);
}
} else {
echo display_form();
}
?>
</body>
</html>
示例8: table_exists
/**
* Table Exists
*
* Check if a table exists in the DB or not
*
* @param string $table_name The table name to check for
*
* @return bool true if the table exists, false if not
*/
function table_exists($table_name)
{
$this->get_table_name($table_name);
// Use sql_table_exists if available
if (method_exists($this->db_tools, 'sql_table_exists')) {
$roe = $this->db->return_on_error;
$result = $this->db_tools->sql_table_exists($table_name);
// db_tools::sql_table_exists resets the return_on_error to false always after completing, so we must make sure we set it to true again if it was before
if ($roe) {
$this->db->sql_return_on_error(true);
}
return $result;
}
if (!function_exists('get_tables')) {
global $phpbb_root_path, $phpEx;
include $phpbb_root_path . 'includes/functions_install.' . $phpEx;
}
$tables = get_tables($this->db);
if (in_array($table_name, $tables)) {
return true;
} else {
return false;
}
}
示例9: get_logtables
function get_logtables($link)
{
// Create an array of the column names in the default table
$query = "DESCRIBE " . DEFAULTLOGTABLE;
$result = perform_query($query, $link);
$defaultFieldArray = array();
while ($row = mysql_fetch_array($result)) {
array_push($defaultFieldArray, $row['Field']);
}
// Create an array with the names of all the log tables
$logTableArray = array();
$allTablesArray = get_tables($link);
foreach ($allTablesArray as $value) {
// Create an array of the column names in the current table
$query = "DESCRIBE " . $value;
$result = perform_query($query, $link);
// Get the names of columns in current table
$fieldArray = array();
while ($row = mysql_fetch_array($result)) {
array_push($fieldArray, $row['Field']);
}
// If the current array is identical to the one from the
// DEFAULTLOGTABLE then the name is added to the result
// array.
$diffArray = array_diff_assoc($defaultFieldArray, $fieldArray);
if (!$diffArray) {
array_push($logTableArray, $value);
}
}
return $logTableArray;
}
示例10: connect_check_db
/**
* Used to test whether we are able to connect to the database the user has specified
* and identify any problems (eg there are already tables with the names we want to use
* @param array $dbms should be of the format of an element of the array returned by {@link get_available_dbms get_available_dbms()}
* necessary extensions should be loaded already
*/
function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix, $dbhost, $dbuser, $dbpasswd, $dbname, $dbport, $prefix_may_exist = false, $load_dbal = true, $unicode_check = true)
{
global $phpbb_root_path, $phpEx, $config, $lang;
$dbms = $dbms_details['DRIVER'];
if ($load_dbal) {
// Include the DB layer
include $phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx;
}
// Instantiate it and set return on error true
$sql_db = 'dbal_' . $dbms;
$db = new $sql_db();
$db->sql_return_on_error(true);
// Check that we actually have a database name before going any further.....
if ($dbms_details['DRIVER'] != 'sqlite' && $dbms_details['DRIVER'] != 'oracle' && $dbname === '') {
$error[] = $lang['INST_ERR_DB_NO_NAME'];
return false;
}
// Make sure we don't have a daft user who thinks having the SQLite database in the forum directory is a good idea
if ($dbms_details['DRIVER'] == 'sqlite' && stripos(phpbb_realpath($dbhost), phpbb_realpath('../')) === 0) {
$error[] = $lang['INST_ERR_DB_FORUM_PATH'];
return false;
}
// Check the prefix length to ensure that index names are not too long and does not contain invalid characters
switch ($dbms_details['DRIVER']) {
case 'mysql':
case 'mysqli':
if (strspn($table_prefix, '-./\\') !== 0) {
$error[] = $lang['INST_ERR_PREFIX_INVALID'];
return false;
}
// no break;
// no break;
case 'postgres':
$prefix_length = 36;
break;
case 'mssql':
case 'mssql_odbc':
case 'mssqlnative':
$prefix_length = 90;
break;
case 'sqlite':
$prefix_length = 200;
break;
case 'firebird':
case 'oracle':
$prefix_length = 6;
break;
}
if (strlen($table_prefix) > $prefix_length) {
$error[] = sprintf($lang['INST_ERR_PREFIX_TOO_LONG'], $prefix_length);
return false;
}
// Try and connect ...
if (is_array($db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true))) {
$db_error = $db->sql_error();
$error[] = $lang['INST_ERR_DB_CONNECT'] . '<br />' . ($db_error['message'] ? $db_error['message'] : $lang['INST_ERR_DB_NO_ERROR']);
} else {
// Likely matches for an existing phpBB installation
if (!$prefix_may_exist) {
$temp_prefix = strtolower($table_prefix);
$table_ary = array($temp_prefix . 'attachments', $temp_prefix . 'config', $temp_prefix . 'sessions', $temp_prefix . 'topics', $temp_prefix . 'users');
$tables = get_tables($db);
$tables = array_map('strtolower', $tables);
$table_intersect = array_intersect($tables, $table_ary);
if (sizeof($table_intersect)) {
$error[] = $lang['INST_ERR_PREFIX'];
}
}
// Make sure that the user has selected a sensible DBAL for the DBMS actually installed
switch ($dbms_details['DRIVER']) {
case 'mysqli':
if (version_compare(mysqli_get_server_info($db->db_connect_id), '4.1.3', '<')) {
$error[] = $lang['INST_ERR_DB_NO_MYSQLI'];
}
break;
case 'sqlite':
if (version_compare(sqlite_libversion(), '2.8.2', '<')) {
$error[] = $lang['INST_ERR_DB_NO_SQLITE'];
}
break;
case 'firebird':
// check the version of FB, use some hackery if we can't get access to the server info
if ($db->service_handle !== false && function_exists('ibase_server_info')) {
$val = @ibase_server_info($db->service_handle, IBASE_SVC_SERVER_VERSION);
preg_match('#V([\\d.]+)#', $val, $match);
if ($match[1] < 2) {
$error[] = $lang['INST_ERR_DB_NO_FIREBIRD'];
}
$db_info = @ibase_db_info($db->service_handle, $dbname, IBASE_STS_HDR_PAGES);
preg_match('/^\\s*Page size\\s*(\\d+)/m', $db_info, $regs);
$page_size = intval($regs[1]);
if ($page_size < 8192) {
$error[] = $lang['INST_ERR_DB_NO_FIREBIRD_PS'];
}
//.........这里部分代码省略.........
示例11: get_phpbb_tables
/**
* Get all tables used by phpBB
*/
function get_phpbb_tables()
{
global $db, $table_prefix;
static $_tables = array();
if (!empty($_tables)) {
return $_tables;
}
if (!function_exists('get_tables')) {
include PHPBB_ROOT_PATH . 'includes/functions_install.' . PHP_EXT;
}
// Function returns all tables in the database
$all_tables = get_tables($db);
// Only get tables using the phpBB prefix
if (!empty($table_prefix)) {
foreach ($all_tables as $table) {
if (strpos($table, $table_prefix) === 0) {
$_tables[] = $table;
}
}
} else {
// Use is using an empty table prefix (Bug #62537)
// no way to determine the phpBB tables, in this case
// we'll show everything with a warning that the tool
// most likely want to trash a lot of tables '-,-
global $template;
$template->assign_vars(array('ERROR_MESSAGE' => user_lang('EMPTY_PREFIX_EXPLAIN'), 'ERROR_TITLE' => user_lang('EMPTY_PREFIX')));
$_tables = $all_tables;
}
sort($_tables);
return $_tables;
}
示例12: get_tables
<?php
require_once "data.php";
require_once "connection.php";
//получаем список таблиц из БД
$tables = get_tables($mysql);
if ($_POST) {
$name = $_POST['tables'];
$format = $_POST['formats'];
get_data($name, $format, $mysql);
}
?>
<html lang="ru">
<head>
<meta charset="UTF-8" />
<title>Работа с БД</title>
<link href="style.css" rel="stylesheet" />
</head>
<body>
<div class="wrapper">
<div class="container">
<form action="main.php" method="post">
<select class="tables" id="tables" name="tables">
<?php
echo "<option selected='selected'>Выберите таблицу</option>";
foreach ($tables as $table) {
echo "<option>" . $table[0] . "</option>";
}
?>
</select>
示例13: get_tables
<?php
require_once "main.php";
//получаем список таблиц из БД для выпадающего меню
$tables = get_tables($conn);
if ($_POST) {
$name = $_POST['tables'];
$format = $_POST['formats'];
$m_format = strtolower($format);
if (in_array($name, $tables)) {
switch ($format) {
case "CSV":
create_csv($name, $conn);
break;
case "JSON":
create_json($name, $conn);
break;
case "XML":
create_xml($name, $conn);
break;
default:
echo "<h3>Выберите формат файла!</h3>";
break;
}
//проверяем существование файла
$file = DIR . $m_format . "/" . $name . "." . $m_format;
if (file_exists($file)) {
download_file($file);
}
} else {
echo "<h3>Выберите таблицу из списка!</h3>";
示例14: delete_suggestion
function delete_suggestion(){
global $conn;
$tablename = $_GET['tableName'];
$suggestion_id = $_GET['suggestion_id'];
$token = $_GET['jwt'];
//we dont have to worry about checking what the result is, as as soon as it realizes we arent logged in 401 response header sent and caight by HTTP interceptor
userLoggedIn($token);
flush();
$accepted_tables = get_tables();
if(in_array($tablename, $accepted_tables)){
$tablename = htmlspecialchars($tablename);
$suggestion_id = htmlspecialchars($suggestion_id);
if($sql = $conn->prepare("DELETE FROM $tablename WHERE suggestion_id = ?")){
$sql->bind_param('s', $suggestion_id);
if( !($sql->execute()) ){
echo false;
}
}
}
}
示例15: get_dependencies
$deps = get_dependencies(OT_EXCEPTION, $dname);
if (count($deps) > 0) {
$message = sprintf($MESSAGES['HAVE_DEPENDENCIES'], $acc_strings['Exception'], $dname, dependencies_string($deps));
} else {
if ($s_cust['askdel'] == TRUE) {
$s_confirmations['exc'] = array('msg' => sprintf($MESSAGES['CONFIRM_EXC_DELETE'], $dname), 'obj' => $dname);
} else {
drop_exception($dname);
}
}
}
}
// setup $s_tables[] and $s_fields[] if necessary
if ($s_connected == TRUE && $s_tables_valid == FALSE) {
include_once './inc/get_tables.inc.php';
if (get_tables()) {
$s_tables_valid = TRUE;
}
}
//
// deleting of a subject is confirmed
//
if (isset($_POST['confirm_yes'])) {
switch ($_POST['confirm_subject']) {
case 'index':
drop_index($s_confirmations['index']['obj']);
break;
case 'trigger':
drop_trigger($s_confirmations['trigger']['obj']);
break;
case 'domain':