[PHP-users 29180] Re: PEAR の getone() が使えない

佐本 達義 ttsamoto @ yahoo.co.jp
2006年 5月 11日 (木) 17:33:33 JST


いわせ様、鈴木様、tetuo様、アドバイスありがとうございま
す。ご指摘を参考に修正しましたが、同じエラーが出力されて
しまいます。スクリプトとエラー内容は下記のとおりです。
------------------------------------------------------
  $db = DB::connect(DSN, false);
  
  if (PEAR::isError($db)) {
    sprintf("can't connect database.");
  }
------------------------------------------------------
can't connect database.
Fatal error: Call to undefined method DB_Error::getOne()
in C:\Program Files\Apache
Group\Apache2\htdocs\5-1\basic1.php on line 27
------------------------------------------------------

やはり、$dbがDB_Errorオブジェクトとかなのでこのようなエ
ラーが出力されてしまうのか、それとも、ただ単に関数が読み
込めていないだけなのかわかりません。

また、var_dump($db)を挿入してみたところ、次のように出力
されました。
------------------------------------------------------
object(DB_Error)#2 (8) { ["error_message_prefix"]=>
string(0) "" ["mode"]=> int(1) ["level"]=> int(1024)
["code"]=> int(-14) ["message"]=> string(30) "DB Error: no
database selected" ["userinfo"]=> string(104) "
[nativecode=file is encrypted or is not a database] **
sqlite://dummy:@localhost//tmp/user.db?mode=0644"
["backtrace"]=> array(6) { [0]=> array(6) { ["file"]=>
string(19) "C:\php5\PEAR\DB.php" ["line"]=> int(888)
["function"]=> string(10) "PEAR_Error" ["class"]=>
string(8) "DB_Error" ["type"]=> string(2) "->" ["args"]=>
array(5) { [0]=> string(30) "DB Error: no database
selected" [1]=> int(-14) [2]=> int(1) [3]=> int(1024)
[4]=> string(52) " [nativecode=file is encrypted or is not
a database]" } } [1]=> array(6) { ["file"]=> string(21)
"C:\php5\PEAR\PEAR.php" ["line"]=> int(563) ["function"]=>
string(8) "DB_Error" ["class"]=> string(8) "DB_Error"
["type"]=> string(2) "->" ["args"]=> array(4) { [0]=>
int(-14) [1]=> int(1) [2]=> int(1024) [3]=> string(52) "
[nativecode=file is encrypted or is not a database]" } }
[2]=> array(6) { ["file"]=> string(26)
"C:\php5\PEAR\DB\common.php" ["line"]=> int(1849)
["function"]=> string(10) "raiseError" ["class"]=>
string(9) "DB_sqlite" ["type"]=> string(2) "->" ["args"]=>
array(7) { [0]=> NULL [1]=> int(-14) [2]=> NULL [3]=> NULL
[4]=> string(52) " [nativecode=file is encrypted or is not
a database]" [5]=> string(8) "DB_Error" [6]=> bool(true) }
} [3]=> array(6) { ["file"]=> string(26)
"C:\php5\PEAR\DB\sqlite.php" ["line"]=> int(245)
["function"]=> string(10) "raiseError" ["class"]=>
string(9) "DB_sqlite" ["type"]=> string(2) "->" ["args"]=>
array(5) { [0]=> int(-14) [1]=> NULL [2]=> NULL [3]=> NULL
[4]=> string(38) "file is encrypted or is not a database"
} } [4]=> array(6) { ["file"]=> string(19)
"C:\php5\PEAR\DB.php" ["line"]=> int(556) ["function"]=>
string(7) "connect" ["class"]=> string(9) "DB_sqlite"
["type"]=> string(2) "->" ["args"]=> array(2) { [0]=>
array(10) { ["phptype"]=> string(6) "sqlite"
["dbsyntax"]=> string(6) "sqlite" ["username"]=> string(5)
"dummy" ["password"]=> string(0) "" ["protocol"]=>
string(3) "tcp" ["hostspec"]=> string(9) "localhost"
["port"]=> bool(false) ["socket"]=> bool(false)
["database"]=> string(12) "/tmp/user.db" ["mode"]=>
string(4) "0644" } [1]=> bool(false) } } [5]=> array(6) {
["file"]=> string(59) "C:\Program Files\Apache
Group\Apache2\htdocs\5-1\basic1.php" ["line"]=> int(17)
["function"]=> string(7) "connect" ["class"]=> string(2)
"DB" ["type"]=> string(2) "::" ["args"]=> array(2) { [0]=>
string(48)
"sqlite://dummy:@localhost//tmp/user.db?mode=0644" [1]=>
bool(false) } } } ["callback"]=> NULL } can't connect
database.
Fatal error: Call to undefined method DB_Error::getOne()
in C:\Program Files\Apache
Group\Apache2\htdocs\5-1\basic1.php on line 29
------------------------------------------------------

samotty

--------------------------------------
Yahoo! JAPAN 10th Anniversary Special Feature
--- Enjoy Yahoo! Auction with Yahoo! Mail !! ---
http://pr.mail.yahoo.co.jp/auction/


PHP-users メーリングリストの案内