<?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($T4j2L, $nzuw7) { goto f2MBn; HmrIC: return $ebM0g; goto hS3xJ; rqYCK: $ebM0g->setTable($nzuw7); goto ObQ9p; f2MBn: $ebM0g = new DynamicModel(); goto rqYCK; ObQ9p: $ebM0g->setConnection($T4j2L); goto HmrIC; hS3xJ: } public static function get($T4j2L, $nzuw7, $hAsFN, $Qirc_ = array('*')) { goto Pn1QV; HLgrC: if (empty($ebM0g)) { return null; } goto k3faY; k3faY: return $ebM0g->toArray(); goto VZg2w; ePh7D: $ebM0g = self::model($T4j2L, $nzuw7)->where($hAsFN)->first($Qirc_); goto HLgrC; Pn1QV: if (is_string($hAsFN) || is_numeric($hAsFN)) { $hAsFN = array('id' => $hAsFN); } goto ePh7D; VZg2w: } public static function insert($T4j2L, $nzuw7, $IaeCl) { goto TFjzY; mnj5a: $ebM0g->save(); goto DB4yA; TFjzY: $ebM0g = self::model($T4j2L, $nzuw7); goto AGTH7; AGTH7: foreach ($IaeCl as $F_a6B => $JiRHR) { $ebM0g->{$F_a6B} = $JiRHR; } goto mnj5a; DB4yA: return $ebM0g->toArray(); goto rq2D0; rq2D0: } public static function insertAll($T4j2L, $nzuw7, $pkSqq, $dwDWG = true) { if ($dwDWG) { foreach ($pkSqq as $JhHfm => $IaeCl) { $pkSqq[$JhHfm]['created_at'] = date('Y-m-d H:i:s'); $pkSqq[$JhHfm]['updated_at'] = date('Y-m-d H:i:s'); } } DB::connection($T4j2L)->table($nzuw7)->insert($pkSqq); } public static function delete($T4j2L, $nzuw7, $hAsFN) { if (is_string($hAsFN) || is_numeric($hAsFN)) { $hAsFN = array('id' => $hAsFN); } return self::model($T4j2L, $nzuw7)->where($hAsFN)->delete(); } public static function update($T4j2L, $nzuw7, $hAsFN, $IaeCl) { goto TQS0w; TQS0w: if (empty($hAsFN)) { return null; } goto eKY5u; BpjC9: if (empty($IaeCl)) { return null; } goto fu04_; eKY5u: if (is_string($hAsFN) || is_numeric($hAsFN)) { $hAsFN = array('id' => $hAsFN); } goto BpjC9; fu04_: return self::model($T4j2L, $nzuw7)->where($hAsFN)->update($IaeCl); goto Q6zMO; Q6zMO: } }