medoo–高效的轻量级PHP数据库操作类

网址:http://medoo.lvtao.net/

  1. /*medoo.php*/
    class medoo
    {
    protected $database_type = ‘mysql’;
    protected $server = ‘localhost’;
    protected $username = ‘your_username’;
    protected $password = ‘your_password’;
    
    }

     

只需三步!

  1.  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();

 

转载于:https://www.cnblogs.com/findgor/p/4086524.html

你可能感兴趣的:(medoo–高效的轻量级PHP数据库操作类)