Medoo 0.8.2更新,超輕量級的PHP SQL框架

jopen 11年前發布 | 12K 次閱讀 Medoo

Medoo 0.8.2更新,超輕量級的PHP SQL框架

Medoo是最近倍受關注的超輕量級PHP SQL框架,特點是超級輕量級,只有一個8KB文件,配置簡單,使用方便,而且還提供防止數據注入,調試等特性,大大提升開發效率。

此次0.8.2版本更新了建立初始化連接的方法,提供更加靈活的接口以應用在各種不同的應用當中。

// Independent configuration
require  'medoo.php';

$database = new medoo([
    // required
    'database_type' => 'mysql',
    'database_name' => 'name',
    'server' => 'localhost',
    'username' => 'your_username',
    'password' => 'your_password',

    // optional
    'charset' => 'utf8',
    // driver_option for connection, read more from http://www.php.net/manual/en/pdo.setattribute.php
    'option' => [
        PDO::ATTR_CASE => PDO::CASE_NATURAL
    ];
]);

$database->insert("account", [
    "user_name" => "foo",
    "email" => "foo@bar.com"
]);

// Or just open the medoo.php and edit some configuration on the top of the file,
// So that you can use it directly without configure again in the further.
// For MySQL, MSSQL, PostgreSQL, Sybase type name
// MySQL -> mysql
// MSSQL -> mssql
// PostgreSQL -> pgsql
// Sybase -> sybase
class medoo
{
    protected $database_type = 'mysql'; // The type name of database

    protected $server = 'localhost';

    protected $username = 'your_username';

    protected $password = 'your_password';

    // Optional
    protected $charset = 'utf8';
    ....

// And get started!
require_once 'medoo.php';

$database = new medoo('my_database');

$database->insert("account", [
    "user_name" => "foo",
    "email" => "foo@bar.com"
]);

官方網站:http://medoo.in

 

GitHub:https://github.com/catfan/Medoo

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!