PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » DB » Bug #2643

Wrong tableinfo

Details

Submitted2004-10-29 11:33 UTC
Frombert at studioemma dot com
Assigneddanielc
StatusBogus
PackageDB
PHP Version4.3.8
OSWindows XP
Roadmaps(Not assigned)

Comments

[2004-10-29 11:33 UTC] bert at studioemma dot com

Description:
------------
Using the latest version of DB and connecting to MySQL (Client API version 3.23.49)
When I ask for the info of a table, then the returned info is not correct with a timestamp. The field ts is a timestamp and is default null. The [flags] says that it is not_null.
print_r gives me
....
[5] => Array(
[table] => testTable
[name] => ts
[type] => timestamp
[len] => 14
[flags] => not_null unsigned zerofill
)
....

Reproduce code:
---------------
$sql = "SELECT * FROM ".$this->table_name." LIMIT 0,1";
$result = $this->db->query($sql);
// Check that $result is not an error
if (DB::isError($result)) {
$this->error[] = array("error" => $result->getMessage());
}
else{
$info = $this->db->tableInfo($result);
print_r($info);
$this->table_columnInfo = $info;
}

Expected result:
----------------
[5] => Array(
[table] => testTable
[name] => ts
[type] => timestamp
[len] => 14
[flags] => unsigned zerofill
)

[2005-02-03 07:18 UTC] bert at studioemma dot com

Sorry for the delay:

<?
if (!isset($_POST["username"]) ||!isset($_POST["pass"]) || !isset($_POST["host"]) || !isset($_POST["db"])){
?>
<form method="POST">
Username: <input type="text" name="username"><br>
Password: <input type="text" name="pass"><br>
Server: <input type="text" name="host" value="localhost"><br>
Database: <input type="text" name="db"><br>
<input type="submit" value="Test">
</form>
<?
}
else {
require_once("DB.php");

$dsn = "mysql://".$_POST["username"].":".$_POST["pass"]."@".$_POST["host"]."/".$_POST["db"];
$db = DB::connect($dsn);
if (DB::isError($db)) {
echo $db->getMessage();
}
$sql = "CREATE TABLE `test` (
`id` int(11) NOT NULL auto_increment,
`modified_user_id` int(11) default NULL,
`update_ts` timestamp(14) NOT NULL,
`active` enum('0','1') default '1',
`itemName` varchar(255) default NULL,
`add_ts` timestamp(14) default NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM";
echo $sql."\n\n\n<br>";
$result = $db->query($sql);
if (DB::isError($result)) {
echo $result->getMessage();
}
else{

$result = $db->query("INSERT INTO test (active, itemName, add_ts) VALUES ('0', 'Test', now())");
if (DB::isError($result)) {
echo $result->getMessage();
}
$result = $db->query("SELECT * FROM test LIMIT 0,1");
if (DB::isError($result)) {
echo $result->getMessage();
}
$info = $db->tableInfo($result);
if (DB::isError($info)) {
echo $info->getMessage();
}
else{
print_r($info);
}
$result = $db->query("DROP TABLE test");
if (DB::isError($result)) {
echo $result->getMessage();
}
}
}
?>