{"id":777,"date":"2007-09-18T01:00:00","date_gmt":"2007-09-17T16:00:00","guid":{"rendered":"https:\/\/ecoop.net\/memo\/2007-09-18-1.html"},"modified":"2026-08-10T14:41:39","modified_gmt":"2026-08-10T05:41:39","slug":"2007-09-18-1","status":"publish","type":"post","link":"https:\/\/www.ecoop.net\/memo\/archives\/2007-09-18-1.html","title":{"rendered":"symfony &#8211; Propel \u3092\u4ef2\u4ecb\u305b\u305a\u306b databases.yml \u306b\u66f8\u304b\u308c\u305f\u8a2d\u5b9a\u3084 DB\u63a5\u7d9a\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u5f97\u308b"},"content":{"rendered":"<p>\nsfDatabaseManager \u30af\u30e9\u30b9\u3092\u4f7f\u3046\u3053\u3068\u3067 Propel \u3088\u308a\u4f4e\u3044\u30ec\u30a4\u30e4\u30fc\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u60c5\u5831\u3092\u5f97\u305f\u308a\u3001(Creaole \u306b\u3088\u308b)\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n\u3053\u306e\u65b9\u6cd5\u3092\u4f7f\u3046\u3068 databases.yml \u306e\u8a2d\u5b9a\u3092\u4e00\u6642\u7684\u306b\u5909\u66f4\u3057\u305f\u4e0a\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30a2\u30af\u30bb\u30b9\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<blockquote><p>$manager = new sfDatabaseManager();<br \/>\n$manager->initialize();                \/\/ \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b database.yml \u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3093\u3067\u521d\u671f\u5316\u3059\u308b\u3002<br \/>\n$db = $manager->getDatabase(&#8220;propel&#8221;); \/\/ &#8220;propel:&#8221; \u4ee5\u4e0b\u3092\u53c2\u7167\u3057\u3001sfDatabase \u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u5f97\u308b\u3002 \u5f15\u6570\u3092\u7701\u7565\u3059\u308b\u3068 default: \u3092\u53c2\u7167\u3059\u308b<br \/>\n&nbsp;<br \/>\n\/\/ database.yml \u306e\u8a2d\u5b9a\u3092\u53c2\u7167\u3059\u308b\u4f8b:<br \/>\necho $db->getParameter(&#8220;phptype&#8221;).&#8221;\\n&#8221;; \/\/ propel: param: phptype: \u3092\u53c2\u7167(&#8220;mysql&#8221; \u306a\u3069)<br \/>\necho $db->getParameter(&#8220;host&#8221;).&#8221;\\n&#8221;; \/\/ propel: param: host: \u3092\u53c2\u7167(localhost \u306a\u3069)<br \/>\necho $db->getParameter(&#8220;database&#8221;).&#8221;\\n&#8221;; \/\/ propel: param: database: \u3092\u53c2\u7167<br \/>\necho $db->getParameter(&#8220;username&#8221;).&#8221;\\n&#8221;; \/\/ propel: param: username: \u3092\u53c2\u7167<br \/>\n&nbsp;<br \/>\n\/\/ databases.yml \u306e\u8a2d\u5b9a\u3092\u4e00\u6642\u7684\u306b\u4e0a\u66f8\u304d\u3059\u308b\u4f8b:<br \/>\n$db->setParameter(&#8220;database&#8221;, null); \/\/ \u7279\u5b9a\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u63a5\u7d9a\u3057\u306a\u3044\u3002<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ (\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304c\u5b58\u5728\u3057\u306a\u304f\u3066\u3082\u30a8\u30e9\u30fc\u306b\u306a\u3089\u306a\u3044\u305f\u3081 <br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/  CREATE DATABASE \u3057\u305f\u3044\u5834\u5408\u3084\u30c6\u30fc\u30d6\u30eb\u3092\u4e00\u5207\u5229\u7528<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/\t \u3057\u306a\u3044\u5834\u5408\u306a\u3069\u306b\u6709\u7528)<br \/>\n&nbsp;<br \/>\n\/\/ \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u306e\u4f8b:<br \/>\n\/\/ databases.yml \u306e\u8a2d\u5b9a\u3092\u3082\u3068\u306b Creole \u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u5f97\u308b<br \/>\n\/\/ (vendor\/creole\/Connelction.php \u3067\u5b9a\u7fa9\u3055\u308c\u308b Connection \u62bd\u8c61\u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9)<br \/>\n$con = $db->getConnection();<br \/>\n&nbsp;<br \/>\n$rs = $con->executeQuery(&#8220;SELECT CURRENT_TIMESTAMP AS time&#8221;); \/\/ \u30af\u30a8\u30ea\u3092\u767a\u884c\u3002<br \/>\nwhile($rs->next()){                  \/\/ \u30dd\u30a4\u30f3\u30bf\u3092\u9032\u3081\u308b(\u8907\u6570\u30ec\u30b3\u30fc\u30c9\u5bfe\u5fdc)<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;$row = $rs->getRow();            \/\/ \u30ec\u30b3\u30fc\u30c9\u3092\u9023\u60f3\u914d\u5217\u3067\u53d6\u5f97<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;echo $row[&#8220;time&#8221;];<br \/>\n}\n<\/p><\/blockquote>\n<p>&nbsp;<br \/>\n\u53c2\u8003:<br \/>\n&#8211; <a href=\"http:\/\/www.symfony-project.com\/api\/1_0\/sfDatabaseManager\">Class sfDatabaseManager<\/a>(symfony API)<br \/>\n&nbsp;sfDatabaseManager \u306e\u30af\u30e9\u30b9\u5b9a\u7fa9\u3002<br \/>\n&nbsp;<br \/>\n&#8211; <a href=\"http:\/\/www.symfony-project.com\/api\/1_0\/sfDatabase\">Class sfDatabase<\/a>(symfony API)<br \/>\n&nbsp;sfDatabaseManager::getDatabase() \u3067\u5f97\u3089\u308c\u308b\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u5b9a\u7fa9\u3002<br \/>\n&nbsp;<br \/>\n&#8211; SymfonyAPI &#8211; Connection Interface Reference(cpr.in-berlin.de \u306b\u3088\u308b symfony \u306e phpdoc)<br \/>\n&nbsp;sfDatabase::getConnection() \u3067\u5f97\u3089\u308c\u308b\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u5b9a\u7fa9\u3002<br \/>\n&nbsp;<br \/>\n&#8211; SymfonyAPI &#8211; ResultSet Interface Reference(\u540c\u4e0a)<br \/>\n&nbsp;Connection::executeQuery() \u3067\u5f97\u3089\u308c\u308b\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u5b9a\u7fa9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>sfDatabaseManager \u30af\u30e9\u30b9\u3092\u4f7f\u3046\u3053\u3068\u3067 Propel \u3088\u308a\u4f4e\u3044\u30ec\u30a4\u30e4\u30fc\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u60c5\u5831\u3092\u5f97\u305f\u308a\u3001(Creaole \u306b\u3088\u308b)\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 \u3053\u306e\u65b9\u6cd5\u3092\u4f7f\u3046\u3068 databases. &hellip; <a href=\"https:\/\/www.ecoop.net\/memo\/archives\/2007-09-18-1.html\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">symfony &#8211; Propel \u3092\u4ef2\u4ecb\u305b\u305a\u306b databases.yml \u306b\u66f8\u304b\u308c\u305f\u8a2d\u5b9a\u3084 DB\u63a5\u7d9a\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u5f97\u308b<\/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":[141],"tags":[32],"class_list":["post-777","post","type-post","status-publish","format-standard","hentry","category-lifehack","tag-php"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts\/777","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=777"}],"version-history":[{"count":2,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts\/777\/revisions"}],"predecessor-version":[{"id":1701,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts\/777\/revisions\/1701"}],"wp:attachment":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/media?parent=777"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/categories?post=777"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/tags?post=777"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}