Re: PHP/mysql equivalent of PEAR's tableInfo()??
| From: | Daniel Brown | Date: | Sun, 12 Jul 2009 00:15:32 +0000 |
| Subject: | Re: PHP/mysql equivalent of PEAR's tableInfo()?? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-295257@lists.php.net to get a copy of this message | ||
On Sat, Jul 11, 2009 at 19:57, Govinda<govinda.webdnatalk@gmail.com> wrote:
> I have been using PEAR's tableInfo() to remind myself about the columns in
> the table.. but now I want to see as much data as possible about the table
> and its contents *without* using PEAR. (I.e. just using built in stuff for
> mysqli.)
This is not mysqli_#() directly, but just mocked up here in this
email. Not guaranteed to work, but should give you the right idea at
least. ;-P
<?php
include('inc/config.php'); // Your configuration
include('inc/db.php'); // Your database connection info
$sql = "SHOW TABLES";
$result = mysql_query($sql);
foreach(mysql_fetch_assoc($result) as $k => $v) {
$ssql = "DESCRIBE ".mysql_real_escape_string($v);
$rresult = mysql_query($ssql);
echo "<b>".$k."</b>:<br />\n";
echo "<pre>\n";
print_r(mysql_fetch_assoc($rresult));
echo "</pre>\n";
echo "<br />\n";
}
?>
--
</Daniel P. Brown>
daniel.brown@parasane.net || danbrown@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Check out our great hosting and dedicated server deals at
http://twitter.com/pilotpig