Permalink
Browse files

+checkSQLKeyword

  • Loading branch information...
wadelau committed May 14, 2018
1 parent 2e30c09 commit 7617c5d4bb025069225a6677f76388e576a6df92
Showing with 23 additions and 3 deletions.
  1. +3 −2 comm/tblconf.php
  2. +20 −1 comm/tools.function.php
@@ -27,9 +27,10 @@
if(strtolower($field)=='id'){
$field = strtolower($field);
}
else if(strtolower($field) == 'name' || strtolower($field) == 'type'){
else if(strtolower($field) == 'name' || strtolower($field) == 'type'
|| checkSQLKeyword($field)){
$out .= __FILE__.": field:[".$field."] in tbl:[".$tbl
."]. It's bad idea to name a field as 'name' or 'type'. plz change it to xxxname or namexxx.\n";
."]. It's bad idea to name a field as 'name' or 'type' or SQL reserved keywords. plz change it to xxxname or namexxx.\n";
}
$hmfield[$field] = $fieldv;
$hmfield[$field."_default"] = $v['Default'];
@@ -491,4 +491,23 @@ public static function getIp(){
return $ip;
}
}
}
# sql reserved keywords
# xenxin@ufqi, Mon May 14 12:05:27 CST 2018
function checkSQLKeyword($f){
$rtn = 0;
$SQL_R_KW_LIST = 'ABORT,DECIMAL,INTERVAL,PRESERVE,ALL,DECODE,INTO,PRIMARY,ALLOCATE,DEFAULT,LEADING,RESET,ANALYSE,DESC,LEFT,REUSE,ANALYZE,DISTIN
CT,LIKE,RIGHT,AND,DISTRIBUTE,LIMIT,ROWS,ANY,DO,LOAD,SELECT,AS,ELSE,LOCAL,SESSION_USER,ASC,END,LOCK,SETOF,BETWEEN,EXCEPT,MINUS,SHOW,BINARY,EXCLUDE,M
OVE,SOME,BIT,EXISTS,NATURAL,TABLE,BOTH,EXPLAIN,NCHAR,THEN,CASE,EXPRESS,NEW,TIES,CAST,EXTEND,NOT,TIME,CHAR,EXTERNAL,NOTNULL,TIMESTAMP,CHARACTER,EXTR
ACT,NULL,TO,CHECK,FALSE,NULLS,TRAILING,CLUSTER,FIRST,NUMERIC,TRANSACTION,COALESCE,FLOAT,NVL,TRIGGER,COLLATE,FOLLOWING,NVL2,TRIM,COLLATION,FOR,OFF,T
RUE,COLUMN,FOREIGN,OFFSET,UNBOUNDED,CONSTRAINT,FROM,OLD,UNION,COPY,FULL,ON,UNIQUE,CROSS,FUNCTION,ONLINE,USER,CURRENT,GENSTATS,ONLY,USING,CURRENT_CA
TALOG,GLOBAL,OR,VACUUM,CURRENT_DATE,GROUP,ORDER,VARCHAR,CURRENT_DB,HAVING,OTHERS,VERBOSE,CURRENT_SCHEMA,IDENTIFIER_CASE,OUT,VERSION,CURRENT_SID,ILI
KE,OUTER,VIEW,CURRENT_TIME,IN,OVER,WHEN,CURRENT_TIMESTAMP,INDEX,OVERLAPS,WHERE,CURRENT_USER,INITIALLY,PARTITION,WITH,CURRENT_USERID,INNER,POSITION,
WRITE,CURRENT_USEROID,INOUT,PRECEDING,RESET,DEALLOCATE,INTERSECT,PRECISION,REUSE,DEC';
$f = strtoupper($f);
if(inList($f, $SQL_R_KW_LIST)){
$rtn = 1;
}
return $rtn;
}

0 comments on commit 7617c5d

Please sign in to comment.