首先我們們先安裝Medoo
composer require catfan/Medoo
一個簡單的列子
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Medoo\Medoo;
use \PDO;
class TaskController extends Controller
{
public function index()
{
$config=[
'database_type' => 'mysql',
'database_name' => 'database',
'server' => '127.0.0.1',
'username' => 'username',
'password' => 'password',
'charset' => 'utf8',
'port' => 3306,
'prefix' => 'sys_',
'option' => [PDO::ATTR_CASE => PDO::CASE_NATURAL]
];
$database=new Medoo($config);
$list = $database->select("dic", ["key", "value"], ["type" => "ident"]);
dd($list);
}
}
結果
當然我還是推薦最好還是使用laravel自帶的ORM,也是很強大的。 medoo 中文手冊