mysql正则匹配Y-m-d Y/m/dYmd
//判断时间格式Y-m-d H:i:s或Y/m/d H:i:s
public function checkDateValid($field){
$sql = "SELECT count(*) as count FROM ".$this->tableName." WHERE ".$field."!='' and ".$field." NOT REGEXP '^[0-9]{4}[-\/][0-9]{1,2}[-\/][0-9]{1,2} [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}$'";
\PhalApi\DI()->logger->log('log', 'log', ['msg'=>$sql]);
return $this->getORM()->queryAll($sql);
}
//判断时间格式Y-m-d或Y/m/d或Ymd
public function checkDtValid($field){
$sql = "SELECT count(*) as count FROM ".$this->tableName." WHERE ".$field."!='' and ".$field." NOT REGEXP '^[0-9]{4}(?:-|/)?[0-9]{1,2}(?:-|/)?[0-9]{1,2}$'";
\PhalApi\DI()->logger->log('log', 'log', ['msg========='=>$sql]);
return $this->getORM()->queryAll($sql);
}