码迷,mamicode.com
首页 > 数据库 > 详细

Illuminate\Database\Capsule\Manager数据库操纵封装类

时间:2020-06-24 15:44:16      阅读:102      评论:0      收藏:0      [点我收藏+]

标签:highlight   connect   define   namespace   pass   package   order   sort   sel   

刘超 2020/6/20 16:31:57
$device_info = Capsule::table(‘zh_device_info‘)->where(‘sn‘, $sn)->first()
$updateStart = Capsule::table(‘zh_app_download‘)->where(‘id‘, $DownloadInfo[‘id‘])->update($deviceInfo);、
Capsule::table(‘oauth_clients‘)->insert([
    ‘id‘        =>  ‘testclient‘,
    ‘secret‘    =>  ‘secret‘,
    ‘name‘      =>  ‘Test Client‘,
]);
Capsule::table(‘zh_app_version‘)->where(‘app_id‘, $DownloadInfo[‘app_id‘])->increment(‘install_cnt‘, 1);
Capsule::table(‘coll_app_list‘)->where(‘sn‘,$sn)->delete();

            // 添加帐号
            $mem_data = array(
                ‘role_id‘  => $role_id,
                ‘username‘ => $username,
                ‘password‘ => $password,
                ‘nickname‘ => $username,
                ‘verify_status‘ => 1,
                ‘auth_status‘   => 1,
                ‘regist_time‘   => $now,
                ‘regist_ip‘     => $_SERVER[‘REMOTE_ADDR‘],
                ‘update_time‘    => $now
            );
            $mem_id = Capsule::table(‘zh_member‘)->insertGetId($mem_data);
            //$mch_info = Capsule::table(‘zh_merchant‘)->find($mem_id);

$del_info = Capsule::table(‘coll_app_list‘)->where(‘sn‘,$sn)->select();
$last_upload = Capsule::table(‘coll_app_list‘)->where(‘sn‘, $sn)->orderBy(‘create_at‘, ‘desc‘)->first();
$cate = Capsule::table(‘zh_app_category‘)->find($data[‘app_cate_id‘], array(‘name‘));

刘超 2020/6/20 16:33:20
$list = Capsule::select($sql);

刘超 2020/6/20 16:34:09
$app_list_sql = Capsule::table(‘zh_app_version as version‘)
                                            ->leftJoin(‘zh_apps as apps‘, ‘apps.id‘, ‘=‘, ‘version.app_id‘)
                                            ->whereIn(‘version.id‘, $list);

                    if ($classify) {
                        $app_list_sql->where(‘apps.app_cate_id‘, $cate_id);
                    }

                    if( trim($device[‘app_sort_field‘])  
                        && trim($device[‘app_sort_mode‘])
                        && in_array( trim($device[‘app_sort_mode‘]), [‘asc‘, ‘desc‘, ‘ASC‘, ‘DESC‘] )   
                        && in_array( trim($device[‘app_sort_field‘]), [‘id‘,‘app_id‘,‘package‘,‘version‘,‘size‘,‘download_cnt‘,‘install_cnt‘] ) ){
                        $app_list_sql->orderBy(‘apps.‘.$device[‘app_sort_field‘], $device[‘app_sort_mode‘]);
                    }elseif( trim($device[‘app_sort_field‘])

刘超 2020/6/20 16:38:10
Capsule::schema()->create(‘oauth_access_token_scopes‘, function ($table) {
    $table->increments(‘id‘)->unsigned();
    $table->string(‘access_token‘);
    $table->string(‘scope‘);

    $table->foreign(‘access_token‘)->references(‘access_token‘)->on(‘oauth_access_tokens‘)->onDelete(‘cascade‘);
    $table->foreign(‘scope‘)->references(‘id‘)->on(‘oauth_scopes‘)->onDelete(‘cascade‘);

刘超 2020/6/20 16:38:19
The following code will define the constant "MESSAGE" in the global namespace (i.e. "\MESSAGE").

<?php
namespace test;
define(‘MESSAGE‘, ‘Hello world!‘);
?>

The following code will define two constants in the "test" namespace.

<?php
namespace test;
define(‘test\HELLO‘, ‘Hello world!‘);
define(__NAMESPACE__ . ‘\GOODBYE‘, ‘Goodbye cruel world!‘);
?>

刘超 2020/6/20 16:38:23


use Illuminate\Database\Capsule\Manager as Capsule;
include __DIR__.‘/../vendor/autoload.php‘;

include __DIR__.‘/config.php‘;
include __DIR__.‘/function.php‘;

$capsule = new Capsule();

$capsule->addConnection([
  ‘driver‘    => ‘mysql‘,
  ‘host‘      => ‘127.0.0.1‘,
  ‘database‘  => ‘xxxxxx‘,
  ‘username‘  => ‘root‘,
  ‘password‘  => ‘xxxxxx‘,
  ‘charset‘   => ‘utf8‘,
  ‘collation‘ => ‘utf8_general_ci‘,
  ‘prefix‘    => ‘‘
]);

$capsule->setAsGlobal();

刘超 2020/6/20 16:39:17


$version_detail = Capsule::table(‘zh_app_version‘)->where(‘id‘, $release_info[‘version_id‘])->where(‘status‘, 1)->first();
 $version_detail->toSql();

 

Illuminate\Database\Capsule\Manager数据库操纵封装类

标签:highlight   connect   define   namespace   pass   package   order   sort   sel   

原文地址:https://www.cnblogs.com/hnhycnlc888/p/13187730.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!