Keires_DB


                  id:koyhoge



2010   10   3                  1
http://openpear.org/package/Keires_DB/


            2010-10-03 09:04 0.1.0-alpha




2010   10   3                                    2
about me

                •            (        )

                • id: koyhoge (   )

                •
                •

2010   10   3                             3
Keires_DB
                • O/R                          DB



                • PDO
                •
                  • late static binding, __callStatic
                  • PHP-5.3.0
2010   10   3                                           4
DB


                CREATE TABLE hogetbl (
                      col1    INTEGER PRIMARY KEY,
                      col2    TEXT,
                      col3    TIMESTAMP,
                      col4    BOOLEAN
                  );




2010   10   3                                        5
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
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
// 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
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
•                     w

                • SQL
                •       PRIMARY KEY

                •       PRIMARY KEY



2010   10   3                             10
•   !

                •   DB

                •
                •   PostgreSQL



2010   10   3                    11
http://openpear.org/package/Keires_DB/


            2010-10-03 09:04 0.1.0-alpha




2010   10   3                                    12
FAQ
                Q: Keires     ?
                A:




                             Hecatonchires


2010   10   3                                13
http://bit.ly/keires_db




2010   10   3                             14

Keires_DBリリースのご案内

  • 1.
    Keires_DB id:koyhoge 2010 10 3 1
  • 2.
    http://openpear.org/package/Keires_DB/ 2010-10-03 09:04 0.1.0-alpha 2010 10 3 2
  • 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 extendsKeires_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
  • 12.
    http://openpear.org/package/Keires_DB/ 2010-10-03 09:04 0.1.0-alpha 2010 10 3 12
  • 13.
    FAQ Q: Keires ? A: Hecatonchires 2010 10 3 13
  • 14.