{"id":674,"date":"2006-08-11T01:00:00","date_gmt":"2006-08-10T16:00:00","guid":{"rendered":"https:\/\/ecoop.net\/memo\/2006-08-11-1.html"},"modified":"2006-08-11T01:00:00","modified_gmt":"2006-08-10T16:00:00","slug":"2006-08-11-1","status":"publish","type":"post","link":"https:\/\/www.ecoop.net\/memo\/archives\/2006-08-11-1.html","title":{"rendered":"PHP_Error \u3068\u30a8\u30e9\u30fc\u51e6\u7406"},"content":{"rendered":"<p>\nPEAR \u3092\u5229\u7528\u3057\u3066\u3044\u308b\u3068\u3088\u304f\n<\/p>\n<blockquote><p>$res = $conn->query(&#8220;SELECT no_such_field FROM a_table&#8221;);<br \/>\nif(PEAR::isError($res)){ \/\/ DB::isError($res) \u3082\u540c\u3058<br \/>\n&nbsp;&nbsp;&nbsp;die($res->getMessage()); \/\/ \u30a8\u30e9\u30fc\u8868\u793a\u3057\u3066\u7d42\u4e86<br \/>\n}\n<\/p><\/blockquote>\n<p>\u3068\u3044\u3046\u8868\u8a18\u3092\u3057\u307e\u3059\u304c\u3001\u5168\u3066\u306e PEAR \u30d1\u30c3\u30b1\u30fc\u30b8\u306b\u3064\u3044\u3066\u7d71\u4e00\u7684\u306b\u30a8\u30e9\u30fc\u51e6\u7406\u3057\u305f\u3044\u5834\u5408\u306f <a href=\"http:\/\/pear.php.net\/manual\/ja\/core.pear.pear.seterrorhandling.php\">PEAR::setErrorHandling()<\/a> \u3068\u3044\u3046\u30e1\u30bd\u30c3\u30c9\u304c\u6709\u7528\u3067\u3059\u3002<br \/>\n&nbsp;<br \/>\n\u305f\u3068\u3048\u3070\u3001\u6b21\u306e\u30b3\u30fc\u30c9\u306f\u4e0a\u306e\u3082\u306e\u3068\u540c\u69d8\u306e\u7d50\u679c\u306b\u306a\u308a\u307e\u3059\u3002\n<\/p>\n<blockquote><p>\/\/ PEAR_ERROR_DIE: PEAR_Error \u304c\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5316\u3055\u308c\u305f\u3089 getMessage() \u3092\u51fa\u529b\u3057\u3066\u7d42\u4e86\u3059\u308b\u3088\u3046\u306b\u3059\u308b\u3002<br \/>\nPEAR::setErrorHandling(PEAR_ERROR_DIE);<br \/>\n\/\/ \u3042\u3068\u306f\u666e\u901a\u306b\u5b9f\u884c<br \/>\n$res = $conn->query(&#8220;SELECT no_such_field FROM a_table&#8221;);<br \/>\n\/\/ \u203b\u3053\u3053\u3067\u30a8\u30e9\u30fc\u51e6\u7406\u306f\u4e0d\u8981\uff01\n<\/p><\/blockquote>\n<p>&nbsp;<br \/>\n\u8a73\u7d30\u306a\u30a8\u30e9\u30fc\u51e6\u7406\u3092\u884c\u3044\u305f\u3044\u5834\u5408\u306f PEAR_ERROR_CALLBACK \u3092\u5229\u7528\u3057\u307e\u3059\u3002\n<\/p>\n<blockquote><p>\/\/ \u4f8b1:<br \/>\nPEAR::setErrorHandling(PEAR_ERROR_CALLBACK, &#8220;var_dump&#8221;);<br \/>\n\/\/ \u30a8\u30e9\u30fc\u767a\u751f\u6642\u306b <br \/>\n\/\/ if(PEAR::isError($res)){ var_dump($res); } <br \/>\n\/\/ \u3068\u3059\u308b\u306e\u3068\u7b49\u4fa1<br \/>\n&nbsp;<br \/>\n\/\/ \u4f8b2:<br \/>\nPEAR::setErrorHandling(PEAR_ERROR_CALLBACK, &#8220;error_exit&#8221;);<br \/>\nfunction error_exit($pear_err){ <br \/>\n&nbsp;&nbsp;die($pear_err->getMessage().&#8221;:&#8221;.$pear_getDebugInfo()); <br \/>\n}<br \/>\n\/\/ \u30a8\u30e9\u30fc\u767a\u751f\u6642\u306b\u30e6\u30fc\u30b6\u5b9a\u7fa9\u95a2\u6570 error_exit \u3092\u547c\u3073\u51fa\u3059\u306e\u3068\u7b49\u4fa1\n<\/p><\/blockquote>\n<p>&nbsp;<br \/>\nstatic \u306b\u547c\u3070\u305a\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u30e1\u30bd\u30c3\u30c9\u3068\u3057\u3066 setErrroHandling \u3092\u30b3\u30fc\u30eb\u3057\u305f\u5834\u5408\u3001\u305d\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b\u3064\u3044\u3066\u306e\u307f\u3001\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\u3057\u307e\u3059\u3002<br \/>\n&nbsp;<br \/>\n\u53c2\u8003:<br \/>\n&#8211; <a href=\"http:\/\/pear.php.net\/manual\/ja\/core.pear.pear.intro.php\">PEAR \u57fa\u5e95\u30af\u30e9\u30b9 &#8211; \u306f\u3058\u3081\u306b<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>PEAR \u3092\u5229\u7528\u3057\u3066\u3044\u308b\u3068\u3088\u304f $res = $conn->query(&#8220;SELECT no_such_field FROM a_table&#8221;); if(PEAR::isError($res)){ &hellip; <a href=\"https:\/\/www.ecoop.net\/memo\/archives\/2006-08-11-1.html\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">PHP_Error \u3068\u30a8\u30e9\u30fc\u51e6\u7406<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[32],"class_list":["post-674","post","type-post","status-publish","format-standard","hentry","tag-php"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts\/674","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/comments?post=674"}],"version-history":[{"count":0,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts\/674\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/media?parent=674"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/categories?post=674"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/tags?post=674"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}