|
|
|
|
$dbname = 'tss';
if (!mysql_connect('localhost', root', 'root')) {
print 'Could not connect to mysql';
exit;
}
$result1 = mysql_list_tables($dbname);
if (!$result1) {
print "DB Error, could not list tables\n";
print 'MySQL Error: ' . mysql_error();
exit;
}
while ($row = mysql_fetch_row($result1)) {
echo "Структура таблицы: $row[0] <br>";
echo "=====================================<br>";
$result = mysql_query("SELECT * FROM $row[0]");
$fields = mysql_num_fields($result);
$rows = mysql_num_rows($result);
$table = mysql_field_table($result, 0);
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);
echo $name." $type $len ".$flags."<br>\n";
}
}
mysql_free_result($result1);
|
вот что выводит
Структура таблицы: db_banner
==========================
banner_id int 11 not_null primary_key unsigned auto_increment
banner_link blob 65535 not_null blob
banner_text blob 65535 not_null blob
banner_image blob 65535 not_null blob
Структура таблицы: db_news
==========================
news_id int 11 not_null primary_key unsigned auto_increment
news_title string 200 not_null
news_text blob 65535 not_null blob
news_date date 10 not_null binary
|
как сделать так чтобы выводилось news_title varchar(200) not_null вместо news_title string 200 not_null??? помогите очень надо | |
|
|
|
|
|
|
|
для: safe_mod
(25.02.2007 в 11:42)
| | Можно воспользоваться регулярными выражениями для замены
<?php
$text = "как сделать так чтобы выводилось
news_title varchar(200) not_null
вместо news_title string 200 not_null???";
$pattern = "| string ([\d]+)|i";
$text = preg_replace($pattern, " varchar(\\1)", $text);
echo $text;
?>
|
| |
|
|
|
|
|
|
|
для: cheops
(25.02.2007 в 12:16)
| | А можно как-нибудь получить значение строки из mysql? | |
|
|
|
|
|
|
|
для: safe_mod
(25.02.2007 в 12:28)
| | Можно, вас какая строка интересует? | |
|
|
|
|
|
|
|
для: cheops
(25.02.2007 в 12:45)
| | Вот эта допустим
banner_id int 11 not_null primary_key unsigned auto_increment
чтобы вместо нее было banner_id int(11) not_null primary_key unsigned auto_increment
можно ли эти все параметры вывести из средствами mysql? | |
|
|
|
|
|
|
|
для: safe_mod
(25.02.2007 в 13:06)
| | Хм... ну точно также как для varchar выше... | |
|
|
|
|
|
|
|
для: cheops
(25.02.2007 в 14:09)
| | ок, спасибо | |
|
|
|