~~~
<?php
namespace app\index\model;
use app\common\model\RemoteModel;
use think\Db;
use think\Model;
class Devretention extends RemoteModel
{
protected $connection = 'mysql://root:JB6MUn64xICo@rm-bp1h205f36fv8pecto.mysql.rds.aliyuncs.com:3306/dragon#utf8';
/**
* 返回数据表主键ID最大值
*
* @return int 当前id最大值
*/
public function getRecentDate()
{
try {
$sql = "select date from `devretention` order by `date` desc limit 1";
$Db = Db::connect($this->connection);
$res = $Db->query($sql);
return $res ? $res[0]['date'] : null;
} catch (\Exception $e) {
throw new \think\Exception('异常消息:' . $e->getMessage());
}
}
}
~~~