PEAR::DB Not Work In Class
| From: | Stanley Chan | Date: | Tue, 13 Jan 2004 07:36:56 +0000 |
| Subject: | PEAR::DB Not Work In Class | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-10144@lists.php.net to get a copy of this message | ||
I am using PEAR:B in my own class but it did not work.
When PEAR:B is used in my main code only, it can work.
What is wrong in my class?
Class file is attached, Main Code is shown as the
following; After running the code, it shows:
Error 1 : Result: 0 Error 2: DB Error: unknown error
Why is the unknown error?
<?php
include_once("pear/DB.php");
include_once("tekilib/dbsqlctl.php");
// Login Information for accessing Database
$user = 'root';
$pass = 'password';
$host = 'localhost';
$db_name = 'fshl';
// Data Source Name: This is the universal connection
string
$dsn = "mysql://$user:$pass@$host/$db_name";
$dbMgr = new DBSQLCtl($dsn);
echo "Error 1 : ".$dbMgr->getErrMsg()."\n";
$sql = "select * from fabrication";
$listRecord = $dbMgr->getRecordBySQL($sql);
echo "Result: ".count($listRecord)."\n";
echo "Error 2: ".$dbMgr->getErrMsg();
?>
My main code can work only if it is changed as
...
$sql = "select * from fabrication";
$result = $dbMgr->dbLink->query($sql);
echo $result;
while($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
{
echo "id: ".$row['fabricationid']." =
".$row['name']."<br>";
}
...
PEAR:B can work in my main code but not in my own
created class. What is the problem?
_________________________________________________________
Shining Friends、好心好報、歲月如歌...
浪漫鈴聲 情心連繫
http://ringtone.yahoo.com.hk/