本文整理汇总了PHP中mysql_list_tables函数的典型用法代码示例。如果您正苦于以下问题:PHP mysql_list_tables函数的具体用法?PHP mysql_list_tables怎么用?PHP mysql_list_tables使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysql_list_tables函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create_backup_sql
function create_backup_sql($file)
{
$line_count = 0;
$db_connection = $this->db_connect();
mysql_select_db($this->db_name(), $db_connection) or die("ERROR: Unable to connect database (code:m_s_db)");
$tables = mysql_list_tables($this->db_name());
$sql_string = NULL;
while ($table = mysql_fetch_array($tables)) {
$table_name = $table[0];
$sql_string = "DELETE FROM {$table_name}";
$table_query = mysql_query("SELECT * FROM `{$table_name}`");
$num_fields = mysql_num_fields($table_query);
while ($fetch_row = mysql_fetch_array($table_query)) {
$sql_string .= "INSERT INTO {$table_name} VALUES(";
$first = TRUE;
for ($field_count = 1; $field_count <= $num_fields; $field_count++) {
if (TRUE == $first) {
$sql_string .= "'" . mysql_real_escape_string($fetch_row[$field_count - 1]) . "'";
$first = FALSE;
} else {
$sql_string .= ", '" . mysql_real_escape_string($fetch_row[$field_count - 1]) . "'";
}
}
$sql_string .= ");";
if ($sql_string != "") {
$line_count = $this->write_backup_sql($file, $sql_string, $line_count);
}
$sql_string = NULL;
}
}
return $line_count;
}
示例2: getMysqlDump
function getMysqlDump()
{
mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
$tables = mysql_list_tables(DB_NAME);
while ($td = mysql_fetch_array($tables)) {
$table = $td[0];
if ($table == $this->_tableName) {
continue;
}
$SQL[] .= "DROP TABLE IF EXISTS `{$table}`;";
$r = mysql_query("SHOW CREATE TABLE `{$table}`");
if ($r) {
$insert_sql = "";
$d = mysql_fetch_array($r);
$d[1] .= ";";
$SQL[] = $d[1];
$table_query = mysql_query("SELECT * FROM `{$table}`");
$num_fields = mysql_num_fields($table_query);
while ($fetch_row = mysql_fetch_array($table_query)) {
$insert_sql .= "INSERT INTO {$table} VALUES(";
for ($n = 1; $n <= $num_fields; $n++) {
$m = $n - 1;
$insert_sql .= "\"" . mysql_real_escape_string($fetch_row[$m]) . "\", ";
$insert_sql = str_replace("'", "\\'", $insert_sql);
}
$insert_sql = substr($insert_sql, 0, -2);
$insert_sql .= ");\n";
}
if ($insert_sql != "") {
$SQL[] = $insert_sql;
}
}
}
return implode("\r", $SQL);
}
示例3: cw_cpanel_check_fields
function cw_cpanel_check_fields($fields, &$check)
{
$check = array();
$check['path'] = is_writable($fields['path']);
$mylink = @mysql_connect($fields['mysql_host'], $fields['mysql_user'], $fields['mysql_password'], true);
$check['mysql_host'] = $mylink ? true : false;
if ($mylink) {
$check['mysql_database'] = @mysql_select_db($fields['mysql_db'], $mylink) ? true : false;
}
if ($check['path']) {
$check['skins'] = is_dir($fields['path'] . '/skins');
}
if ($check['mysql_database']) {
$res = @mysql_list_tables($fields['mysql_db'], $mylink);
$check['tables'] = false;
while ($row = @mysql_fetch_row($res)) {
$ctable = $row[0];
if ($ctable == 'ars_products' || $ctable == 'ars_customers') {
$check['tables'] = true;
break;
}
}
}
@mysql_close($mylink);
$required_fields = array('path', 'mysql_host', 'mysql_database');
$is_no_error = true;
foreach ($required_fields as $val) {
$is_no_error &= $check[$val];
}
return $is_no_error;
}
示例4: GetTables
function GetTables()
{
$xmlOutput = "";
$result = mysql_list_tables($this->database, $this->connectionId);
if ($result) {
$xmlOutput = "<RESULTSET><FIELDS>";
// Columns are referenced by index, so Schema and
// Catalog must be specified even though they are not supported
$xmlOutput .= "<FIELD><NAME>TABLE_CATALOG</NAME></FIELD>";
// column 0 (zero-based)
$xmlOutput .= "<FIELD><NAME>TABLE_SCHEMA</NAME></FIELD>";
// column 1
$xmlOutput .= "<FIELD><NAME>TABLE_NAME</NAME></FIELD>";
// column 2
$xmlOutput .= "</FIELDS><ROWS>";
$tableCount = mysql_num_rows($result);
for ($i = 0; $i < $tableCount; $i++) {
$xmlOutput .= "<ROW><VALUE/><VALUE/><VALUE>";
$xmlOutput .= mysql_tablename($result, $i);
$xmlOutput .= "</VALUE></ROW>";
}
$xmlOutput .= "</ROWS></RESULTSET>";
}
return $xmlOutput;
}
示例5: Sorgu
public function Sorgu($Sorgum, $Secim = "0", $FF = null)
{
$this->DBCon = mysql_connect($this->DBServer, $this->DBUser, $this->DBUserPass) or die('MySQL connect failed. ' . mysql_error());
mysql_select_db($this->DBName, $this->DBCon);
switch ($Secim) {
case "0":
return mysql_query($Sorgum);
break;
case "1":
$Al = mysql_query($Sorgum);
return @mysql_fetch_array($Al, MYSQL_NUM);
break;
case "2":
$Al = mysql_query($Sorgum);
return mysql_num_rows($Al);
break;
case "3":
$Al = @mysql_list_tables($this->DataBaseAdi);
return mysql_fetch_array($Al);
break;
case "4":
$Al = @mysql_query($Sorgum);
return mysql_fetch_assoc($Al);
break;
case "5":
$Al = @mysql_query($Sorgum);
return mysql_fetch_array($Al);
break;
default:
break;
}
}
示例6: dumpData
function dumpData($link, $mdb_name, $live_link)
{
$result = mysql_list_tables($mdb_name, $link);
while ($row = mysql_fetch_row($result)) {
$getdata = mysql_query("SELECT * FROM {$row['0']}", $link);
while ($row1 = mysql_fetch_array($getdata)) {
$thesql = "INSERT INTO `{$row['0']}` VALUES (";
$getcols = mysql_list_fields($mdb_name, $row[0], $link);
for ($c = 0; $c < mysql_num_fields($getcols); $c++) {
$thesql .= "'" . mysql_format($row1[$c]) . "'";
if ($c < mysql_num_fields($getcols) - 1) {
$thesql .= ",";
}
}
$thesql .= ")";
mysql_query("{$thesql}", $live_link);
unset($err);
$err = mysql_error();
if ($err) {
print "Query: " . $tok . "<br>";
print "Error: " . $err . "<br>";
} else {
print ".";
ob_flush();
flush();
}
$thesql = "";
}
}
return true;
}
示例7: create_backup
function create_backup($file)
{
$line_count = 0;
$tables = mysql_list_tables(DB_NAME);
$sql_string = NULL;
while ($table = mysql_fetch_array($tables)) {
$table_name = $table[0];
$sql_string = "\nTRUNCATE {$table_name};\n";
$table_query = mysql_query("SELECT * FROM `{$table_name}`");
$num_fields = mysql_num_fields($table_query);
while ($fetch_row = mysql_fetch_array($table_query)) {
$sql_string .= "INSERT INTO {$table_name} VALUES(";
$first = TRUE;
for ($field_count = 1; $field_count <= $num_fields; $field_count++) {
if (TRUE == $first) {
$sql_string .= "'" . mysql_real_escape_string($fetch_row[$field_count - 1]) . "'";
$first = FALSE;
} else {
$sql_string .= ", '" . mysql_real_escape_string($fetch_row[$field_count - 1]) . "'";
}
}
$sql_string .= ");";
if ($sql_string != "") {
$line_count = write_backup($file, $sql_string, $line_count);
}
$sql_string = NULL;
}
}
return $line_count;
}
示例8: load_db_dump
function load_db_dump($file, $sqlserver, $user, $pass, $dest_db)
{
$sql = mysql_connect($sqlserver, $user, $pass);
$result = mysql_list_tables($dest_db);
while ($table = mysql_fetch_array($result)) {
$query = "DROP TABLE `" . $table[0] . "`";
mysql_query($query);
}
$a = file($file);
foreach ($a as $n => $l) {
if (substr($l, 0, 2) == '--') {
unset($a[$n]);
}
}
$a = explode(";\n", implode("\n", $a));
unset($a[count($a) - 1]);
foreach ($a as $q) {
if ($q) {
if (!mysql_query($q)) {
mysql_close($sql);
}
}
}
mysql_close($sql);
header("Location: " . BASE_URL);
}
示例9: optimaliseer
function optimaliseer()
{
global $sql;
$tabellen = mysql_list_tables($sql['db']);
$totaal = 0;
echo "Size of the Tables:<br /><br />\n <table width=\"600\" border=\"0\" cellspacing=\"2\" cellpadding=\"0\">\n <tr>\n <td width=\"200\"><strong>TABLE</strong></td>\n <td width=\"200\"><strong>BEFORE</STRONG></td>\n <td width=\"200\"><strong>AFTER</strong></td>\n </tr>";
while ($tabel_naam = mysql_fetch_row($tabellen)) {
$grootte1 = 0;
$grootte2 = 0;
$query1 = mysql_query("SHOW TABLE STATUS FROM " . $sql['db'] . " LIKE '" . $tabel_naam[0] . "'") or die(mysql_error());
mysql_query("OPTIMIZE TABLE " . $tabel_naam[0]) or die(mysql_error());
$query2 = mysql_query("SHOW TABLE STATUS FROM " . $sql['db'] . " LIKE '" . $tabel_naam[0] . "'") or die(mysql_error());
while ($data1 = mysql_fetch_assoc($query1)) {
$grootte1 = $grootte1 + floatval($data1["Data_length"]) + floatval($data1["Index_length"]);
}
while ($data2 = mysql_fetch_assoc($query2)) {
$grootte2 = $grootte2 + floatval($data2["Data_length"]) + floatval($data2["Index_length"]);
}
echo "<tr><td>" . $tabel_naam[0] . "</td>";
echo "<td>" . $grootte1 . " bytes</td>";
echo "<td>" . $grootte2 . " bytes</td></tr>";
$totaal += $grootte1 - $grootte2;
mysql_free_result($query1);
mysql_free_result($query2);
}
echo "</tr></table><br /><br />";
echo "Space Saved " . $totaal . " bytes.";
}
示例10: makedump
function makedump($table_select, $what, $db, $crlf = "\n")
{
global $dump_buffer, $tmp_buffer;
$tables = mysql_list_tables($db);
$num_tables = mysql_numrows($tables);
$dump_buffer = '';
$tmp_buffer = '';
$i = 0;
while ($i < $num_tables) {
$table = mysql_tablename($tables, $i);
if (!isset($table_select[$table])) {
$i++;
continue;
}
if ($what != 'dataonly') {
$dump_buffer .= PMA_getTableDef($db, $table, $crlf) . ';' . $crlf . $crlf;
}
if ($what == 'data' || $what == 'dataonly') {
$tmp_buffer = '';
PMA_getTableContent($db, $table, 0, 0, 'PMA_myHandler', $crlf);
$dump_buffer .= $tmp_buffer . $crlf;
}
$i++;
}
return $dump_buffer;
}
示例11: databaseSelected
public function databaseSelected()
{
if (!$this->isConnected()) {
return false;
}
$result = mysql_list_tables($this->name, $this->db);
return is_resource($result);
}
示例12: getalltable_old
public function getalltable_old()
{
@($result = mysql_list_tables($this->basename));
while ($row = mysql_fetch_row($result)) {
$arr[] = $row[0];
}
return $arr;
}
示例13: list_tables
function list_tables()
{
$res = mysql_list_tables($this->db['dbName']);
for ($i = 0; $i < $this->num_rows($res); $i++) {
$fields[$i] = mysql_tablename($res, $i);
}
return $fields;
}
示例14: getTables
function getTables()
{
$res = mysql_list_tables($this->db, $this->conn);
if (!$res) {
throw new Exception(mysql_error(), EXCEPTION_MYSQL);
}
return $res;
}
示例15: db_list_tables
function db_list_tables($error_checking = true)
{
global $MySQL;
$res = mysql_list_tables($MySQL->db);
if ($error_checking && !$res) {
genMySQLErr('Database list tables failed');
}
return $res;
}