多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[数据模型]-查询`date`类型字段最大日期 ~~~ /** * 返回数据表date最新日期 * * @return int 当前id最大值 */ public function getRecentDate() { try { $res = $this->field('date')->order('date desc')->limit(1)->select(); return $res ? $res[0]->date : null; } catch (\Exception $e) { throw new \think\Exception('异常消息:' . $e->getMessage()); } } ~~~ [数据库类]-查询日期最大值 ~~~ <?php namespace app\index\model; use app\common\model\RemoteModel; use think\Db; use think\Model; class Retention extends RemoteModel { protected $connection = ['prefix' => 'acc_dragon_']; /** * 初始化 * * @return void */ protected function initialize() { parent::initialize(); $this->table = 'acc_dragon_retention'; } /** * 返回数据表主键ID最大值 * * @return int 当前id最大值 */ public function getRecentDate() { try { $sql = "select date from `acc_dragon_retention` order by `date` desc limit 1"; $res = Db::query($sql); return $res ? $res[0]['date'] : null; } catch (\Exception $e) { throw new \think\Exception('异常消息:' . $e->getMessage()); } } ~~~