Phalapi use laravel's eloquent orm

Booter

a mini booter of some services .

Installation

Use composer to manage your dependencies and download:

composer require fizzday/booter

Example

  • 1.Eloquent

    • config & boot
     'mysql',
    
                  'connections' => array(
                      'mysql' => array(
                          'driver' => 'mysql',
                          'host' => '192.168.200.248',
                          'port' => '3306',
                          'database' => 'wcc_service_yxpt',
                          'username' => 'gcore',
                          'password' => 'gcore',
                          'charset' => 'utf8',
                          'collation' => 'utf8_unicode_ci',
                          'prefix' => '',
                      ),
                  );
    Booter::bootEloquent($config);
    
    • usage
    First();
    

phalapi 中调用

~/phalapi/config/di.php中添加代码:

 'mysql',

                  'connections' => array(
                      'mysql' => array(
                          'driver' => 'mysql',
                          'host' => '192.168.200.248',
                          'port' => '3306',
                          'database' => 'wcc_service_yxpt',
                          'username' => 'gcore',
                          'password' => 'gcore',
                          'charset' => 'utf8',
                          'collation' => 'utf8_unicode_ci',
                          'prefix' => '',
                      ),
                  );
    $di->db = Booter::bootEloquent($config);
......

当然, 这里可以将配置文件抽取放到单独文件中

你可能感兴趣的:(Phalapi use laravel's eloquent orm)