標籤:style blog http color ar os 使用 sp strong
網址:http://medoo.lvtao.net/
/*medoo.php*/class medoo{protected $database_type = ‘mysql’;protected $server = ‘localhost’;protected $username = ‘your_username’;protected $password = ‘your_password’;}
只需三步!
1 // 引入 Medoo 2 require_once ‘medoo.php’; 3 // 執行個體化 4 $database = new medoo(); 5 // 插入資料例子 6 $database->insert(‘account’, [ 7 ‘user_name‘ => ‘foo‘ 8 ‘email‘ => ‘[email protected]‘, 9 ‘age‘ => 25,10 ‘lang‘ => [‘en‘, ‘fr‘, ‘jp‘, ‘cn‘]11 ]);12 // 或者13 $database = new medoo([14 ‘database_type‘ => ‘mysql‘,15 ‘database_name‘ => ‘name‘,16 ‘server‘ => ‘localhost‘,17 ‘username‘ => ‘your_username‘,18 ‘password‘ => ‘your_password‘,19 ]);
* 只有在 PHP 5.4+, 你可以使用
[] 作為文法. 下面是測試
1 <?php 2 require_once ‘init.php’;//包含執行個體化medoo 3 4 //var_dump($database); 5 // $datas = $db->select(“tab1″,”*”); 6 //$a=$db->query(‘select * from “tab1″ a left join “tab2″ b on a.id=b.pid’)->fetchAll(); 7 8 $a=$db->select(“tab1″, 9 array(“[>]tab2″ => array(“id” => “pid”)),10 array(11 “tab1.id(id1)”,12 “tab2.id(id2)”,13 “tab1.value(v1)”,14 “tab2.value(v2)”,15 )16 );17 var_dump($a);18 // var_dump($datas);19 20 echo $db->last_query();
medoo–高效的輕量級PHP資料庫操作類