Mercurial > epgrec.yaz
diff DBRecord.class.php @ 32:01a8fdc0cebb
testing: Web base setting page.
author | Sushi-k <epgrec@park.mda.or.jp> |
---|---|
date | Mon, 27 Jul 2009 18:48:51 +0900 |
parents | d3ee3927eb3a |
children | e5f9aa34d06f |
line wrap: on
line diff
--- a/DBRecord.class.php Mon Jul 27 11:24:05 2009 +0900 +++ b/DBRecord.class.php Mon Jul 27 18:48:51 2009 +0900 @@ -1,5 +1,6 @@ <?php include_once( 'config.php' ); +include_once( 'Settings.class.php' ); class DBRecord { protected $table; @@ -8,12 +9,14 @@ public $id; function __construct( $table, $property = null, $value = null ) { + $settings = Settings::factory(); + $this->table = $table; - $this->dbh = @mysql_connect( DB_HOST, DB_USER, DB_PASS ); + $this->dbh = @mysql_connect( $settings->db_host , $settings->db_user, $settings->db_pass ); if( $this->dbh === FALSE ) throw new exception( "construct:データベースに接続できない" ); - $sqlstr = "use ".DB_NAME; + $sqlstr = "use ".$settings->db_name; $res = $this->__query($sqlstr); if( $res === false ) throw new exception("construct: " . $sqlstr ); $sqlstr = "set NAMES utf8"; @@ -39,7 +42,9 @@ } function createTable( $tblstring ) { - $sqlstr = "use ".DB_NAME; + $settings = Settings::factory(); + + $sqlstr = "use ".$settings->db_name; $res = $this->__query($sqlstr); if( $res === false ) throw new exception("createTable: " . $sqlstr ); $sqlstr = "CREATE TABLE IF NOT EXISTS ".$this->table." (" .$tblstring.") DEFAULT CHARACTER SET 'utf8'"; @@ -144,4 +149,4 @@ $this->id = 0; } } -?> +?> \ No newline at end of file