<?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($TdEmr, $GMqtO) { goto hjYiW; ulxiW: return $OKbbt; goto ubecP; hjYiW: $OKbbt = new DynamicModel(); goto FF8_6; IQLt7: $OKbbt->setConnection($TdEmr); goto ulxiW; FF8_6: $OKbbt->setTable($GMqtO); goto IQLt7; ubecP: } public static function get($TdEmr, $GMqtO, $s1Lo4, $Q1VPT = array('*')) { goto qVj4V; qVj4V: if (is_string($s1Lo4) || is_numeric($s1Lo4)) { $s1Lo4 = array('id' => $s1Lo4); } goto ySl_0; ySl_0: $OKbbt = self::model($TdEmr, $GMqtO)->where($s1Lo4)->first($Q1VPT); goto wrR1G; wrR1G: if (empty($OKbbt)) { return null; } goto mCLs8; mCLs8: return $OKbbt->toArray(); goto iC3nW; iC3nW: } public static function insert($TdEmr, $GMqtO, $dTnlu) { goto GHvgM; QkV8e: return $OKbbt->toArray(); goto cjz8Y; PAcS_: $OKbbt->save(); goto QkV8e; M39Ee: foreach ($dTnlu as $lxIPA => $knQyJ) { $OKbbt->{$lxIPA} = $knQyJ; } goto PAcS_; GHvgM: $OKbbt = self::model($TdEmr, $GMqtO); goto M39Ee; cjz8Y: } public static function insertAll($TdEmr, $GMqtO, $FJRkb, $BgPIV = true) { if ($BgPIV) { foreach ($FJRkb as $jqibn => $dTnlu) { $FJRkb[$jqibn]['created_at'] = date('Y-m-d H:i:s'); $FJRkb[$jqibn]['updated_at'] = date('Y-m-d H:i:s'); } } DB::connection($TdEmr)->table($GMqtO)->insert($FJRkb); } public static function delete($TdEmr, $GMqtO, $s1Lo4) { if (is_string($s1Lo4) || is_numeric($s1Lo4)) { $s1Lo4 = array('id' => $s1Lo4); } return self::model($TdEmr, $GMqtO)->where($s1Lo4)->delete(); } public static function update($TdEmr, $GMqtO, $s1Lo4, $dTnlu) { goto ozB0B; EiClW: return self::model($TdEmr, $GMqtO)->where($s1Lo4)->update($dTnlu); goto gfw3Z; ozB0B: if (empty($s1Lo4)) { return null; } goto EhCpv; Lc7up: if (empty($dTnlu)) { return null; } goto EiClW; EhCpv: if (is_string($s1Lo4) || is_numeric($s1Lo4)) { $s1Lo4 = array('id' => $s1Lo4); } goto Lc7up; gfw3Z: } }