<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Dao; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Query\Builder; use Illuminate\Support\Facades\DB; class DModelUtil { public static function model($FMbmD, $BWo2e) { goto H9bqG; CivH5: return $JJRD4; goto JNojm; sV823: $JJRD4->setTable($BWo2e); goto xMSNo; xMSNo: $JJRD4->setConnection($FMbmD); goto CivH5; H9bqG: $JJRD4 = new DynamicModel(); goto sV823; JNojm: } public static function get($FMbmD, $BWo2e, $uxPm_, $BpSP0 = array('*')) { goto e4ynu; B0THn: return $JJRD4->toArray(); goto Kwu11; E6EkQ: $JJRD4 = self::model($FMbmD, $BWo2e)->where($uxPm_)->first($BpSP0); goto G6uQZ; e4ynu: if (is_string($uxPm_) || is_numeric($uxPm_)) { $uxPm_ = array('id' => $uxPm_); } goto E6EkQ; G6uQZ: if (empty($JJRD4)) { return null; } goto B0THn; Kwu11: } public static function insert($FMbmD, $BWo2e, $CnWtd) { goto bSdUE; zwl6R: foreach ($CnWtd as $RTHJ6 => $F6Fus) { $JJRD4->{$RTHJ6} = $F6Fus; } goto tZqTX; MrSUQ: return $JJRD4->toArray(); goto VZDSu; bSdUE: $JJRD4 = self::model($FMbmD, $BWo2e); goto zwl6R; tZqTX: $JJRD4->save(); goto MrSUQ; VZDSu: } public static function insertAll($FMbmD, $BWo2e, $X1P5E, $DxK5E = true) { if ($DxK5E) { foreach ($X1P5E as $MqJHJ => $CnWtd) { $X1P5E[$MqJHJ]['created_at'] = date('Y-m-d H:i:s'); $X1P5E[$MqJHJ]['updated_at'] = date('Y-m-d H:i:s'); } } DB::connection($FMbmD)->table($BWo2e)->insert($X1P5E); } public static function delete($FMbmD, $BWo2e, $uxPm_) { if (is_string($uxPm_) || is_numeric($uxPm_)) { $uxPm_ = array('id' => $uxPm_); } return self::model($FMbmD, $BWo2e)->where($uxPm_)->delete(); } public static function update($FMbmD, $BWo2e, $uxPm_, $CnWtd) { goto sI2X9; nToy_: if (is_string($uxPm_) || is_numeric($uxPm_)) { $uxPm_ = array('id' => $uxPm_); } goto xH3ku; fWLIf: return self::model($FMbmD, $BWo2e)->where($uxPm_)->update($CnWtd); goto Cqrp8; xH3ku: if (empty($CnWtd)) { return null; } goto fWLIf; sI2X9: if (empty($uxPm_)) { return null; } goto nToy_; Cqrp8: } }