PHP code example of shijianzhiwai / medoo

1. Go to this page and download the library: Download shijianzhiwai/medoo library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

shijianzhiwai / medoo example snippets


$db = new \Medoo\Medoo([
    'database_type' => 'mysql',
    'database_name' => 'test',
    'server'        => '127.0.0.1',
    'username'      => 'root',
    'password'      => '123456',
    'charset'       => 'utf8',
    'port'          => 3306,
]);

//阿里云RDS读写分离下强制主库查询
$db->forceMaster()->select('test', '*', ['id' => 1]);

//新增的RAW写法 select 部分新增自定义select字段部分
//生成的语句 /*FORCE_MASTER*/SELECT `id` as asName FROM `test` WHERE `id` = 1
$db->forceMaster()->select('test', \Medoo\Medoo::raw('`id` as asName'),  ['id' => 1]);

[
    'database_type' => 'mysql',
    'database_name' => 'test',
    'server'        => '127.0.0.1',
    'username'      => 'root',
    'password'      => '123456',
    'charset'       => 'utf8',
    'port'          => 3306,
]