Contenu connexe
Similaire à Keires_DBリリースのご案内
Similaire à Keires_DBリリースのご案内 (20)
Plus de Tetsuji Koyama (8)
Keires_DBリリースのご案内
- 3. about me
• ( )
• id: koyhoge ( )
•
•
2010 10 3 3
- 4. Keires_DB
• O/R DB
• PDO
•
• late static binding, __callStatic
• PHP-5.3.0
2010 10 3 4
- 5. DB
CREATE TABLE hogetbl (
col1 INTEGER PRIMARY KEY,
col2 TEXT,
col3 TIMESTAMP,
col4 BOOLEAN
);
2010 10 3 5
- 6. class DB_hoge extends Keires_DB_Abstract {
static public $table_name = 'hogetbl';
static public $tupple_info = array(
'col1' => array(
'type' => 'integer',
'primary' => true,
),
'col2' => array(
'type' => 'text',
),
'col3' => array(
'type' => 'timestamp',
),
'col4' => array(
'type' => 'boolean',
),
);
}
2010 10 3 6
- 7. require_once 'Keires/DB.php';
$options = array(
'types' => array(
'default' => array(
'dsn' =>
'pgsql:host=localhost;user=koyama;dbname=koyama',
),
),
);
Keires_DB::init($options);
2010 10 3 7
- 8. // store
$data = array(
'col1' => 1,
'col2' => 'fugahoge',
'col3' => '2010-10-03 12:00:00',
'col4' => false,
);
DB_hoge::store($data);
// read
$row = DB_hoge::getInfo(1);
2010 10 3 8
- 9. SQL
class DB_hoge extends ...
....
public static function findByCol2($val) {
$sql =
'SELECT * FROM ' . self::$table_name .
'WHERE col2=?';
$db = self::getImpl()->getDB();
return $db->getRow($sql, array($val));
}
}
2010 10 3 9
- 10. • w
• SQL
• PRIMARY KEY
• PRIMARY KEY
2010 10 3 10
- 11. • !
• DB
•
• PostgreSQL
2010 10 3 11
- 13. FAQ
Q: Keires ?
A:
Hecatonchires
2010 10 3 13