seiryow/db-php
Composer 安装命令:
composer require seiryow/db-php
包简介
PDO wrapper which enable to use Relational DataBase without SQL.
README 文档
README
PDO wrapper
index.php
//CONNECT DB //SQLITE $dbtype = "sqlite"; $dbname = "./test.db"; $table = "test"; $test = new DB($dbtype, $dbname, $table, null, null); ////MYSQL //$dbtype = "mysql"; //$host = "localhost"; //$dbname = "test"; //$table = "testtbl"; //$user = "root"; //$pass = ""; //$test = new DB($dbtype, "host={$host};dbname={$dbname}", $table, $user, $pass); //CREATE TABLE $schema = array (); $schema["testint"] = "INTEGER"; $schema["testtxt"] = "TEXT"; $test->create($schema); //INSERT $data = array (); $data["testint"] = 123; $test->insert($data); $data["testint"] = 456; $data["testtxt"] = "abc"; $test->insert($data); $data["testint"] = 456; $data["testtxt"] = "xyz"; $test->insert($data); $data["testint"] = 789; $data["testtxt"] = "def"; $test->insert($data); //SELECT ALL $r = $test->selectAll(); //dump($r); //SELECT $where = array (); $where["testint"] = 456; $r = $test->select($where); //dump($r); //UPDATE $where = array (); $update = array (); $where["testint"] = 789; $update["testtxt"] = "ghi"; $test->update($update, $where); $r = $test->select($where); //dump($r); $test->insert($data); $r = $test->selectAll(); //dump($r); //SELECT by LIKE $where = array (); $where["testtxt"] = array ( "like" => "b" ); $r = $test->select($where); //dump($r); //SELECT with AND $where = array (); $where["testint"] = 456; $update["testtxt"] = "xyz"; $r = $test->select($where); //dump($r); //SELECT with OR $where = array (); $where["testtxt"] = array ( "" => "abc", "" => "xyz" ); $r = $test->select($where); //dump($r);
统计信息
- 总下载量: 23
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2014-01-02