|
@@ -842,8 +842,14 @@ class Base
|
|
|
protected function getTableAlias($name)
|
|
|
{
|
|
|
if (!is_string($name) || (
|
|
|
+ // table
|
|
|
!preg_match("/^[a-zA-Z_]+[a-zA-Z0-9_]{0,}$/", $name) &&
|
|
|
- !preg_match("/^`[a-zA-Z_]+[a-zA-Z0-9_]{0,}`$/", $name))
|
|
|
+ // `table`
|
|
|
+ !preg_match("/^`[a-zA-Z_]+[a-zA-Z0-9_]{0,}`$/", $name)) &&
|
|
|
+ // table alias
|
|
|
+ !preg_match("/^[a-zA-Z_]+[a-zA-Z0-9_]{0,}\s+[a-zA-Z]+[a-zA-Z0-9_]{0,}$/", $name) &&
|
|
|
+ // `table` alias
|
|
|
+ !preg_match("/^`[a-zA-Z_]+[a-zA-Z0-9_]{0,}`\s+[a-zA-Z]+[a-zA-Z0-9_]{0,}$/", $name)
|
|
|
) {
|
|
|
if (gettype($name) == 'string') {
|
|
|
throw new TableException("表名不能包含怪字符且不能以数字开头");
|