<?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($SM53V, $w5oww) { goto aoJXJ; EtcHn: return $gOwMM; goto bxc4a; Mvqic: $gOwMM->setConnection($SM53V); goto EtcHn; aoJXJ: $gOwMM = new DynamicModel(); goto Vcn4N; Vcn4N: $gOwMM->setTable($w5oww); goto Mvqic; bxc4a: } public static function get($SM53V, $w5oww, $AMnOB, $cclNa = array('*')) { goto vcc1D; q3Rxq: if (empty($gOwMM)) { return null; } goto otzHj; vcc1D: if (is_string($AMnOB) || is_numeric($AMnOB)) { $AMnOB = array('id' => $AMnOB); } goto SL6FF; otzHj: return $gOwMM->toArray(); goto ZwGXP; SL6FF: $gOwMM = self::model($SM53V, $w5oww)->where($AMnOB)->first($cclNa); goto q3Rxq; ZwGXP: } public static function insert($SM53V, $w5oww, $SjN8A) { goto Nu0ne; mwU32: $gOwMM->save(); goto h0zsQ; Nu0ne: $gOwMM = self::model($SM53V, $w5oww); goto LBon_; h0zsQ: return $gOwMM->toArray(); goto Lmkmp; LBon_: foreach ($SjN8A as $plrwN => $uTz0e) { $gOwMM->{$plrwN} = $uTz0e; } goto mwU32; Lmkmp: } public static function insertAll($SM53V, $w5oww, $VXFj3, $KD8hY = true) { if ($KD8hY) { foreach ($VXFj3 as $UCcmA => $SjN8A) { $VXFj3[$UCcmA]['created_at'] = date('Y-m-d H:i:s'); $VXFj3[$UCcmA]['updated_at'] = date('Y-m-d H:i:s'); } } DB::connection($SM53V)->table($w5oww)->insert($VXFj3); } public static function delete($SM53V, $w5oww, $AMnOB) { if (is_string($AMnOB) || is_numeric($AMnOB)) { $AMnOB = array('id' => $AMnOB); } return self::model($SM53V, $w5oww)->where($AMnOB)->delete(); } public static function update($SM53V, $w5oww, $AMnOB, $SjN8A) { goto tyIBw; zT2Yh: if (empty($SjN8A)) { return null; } goto G4Z8l; G4Z8l: return self::model($SM53V, $w5oww)->where($AMnOB)->update($SjN8A); goto U4l9x; LVbOU: if (is_string($AMnOB) || is_numeric($AMnOB)) { $AMnOB = array('id' => $AMnOB); } goto zT2Yh; tyIBw: if (empty($AMnOB)) { return null; } goto LVbOU; U4l9x: } }