table.column 형식의 쿼리문에 더블쿼터 처리 해 주는 부분을 정규식으로 수정함

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@6707 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
clench 2009-07-17 08:21:07 +00:00
parent 8375388099
commit ea7ab79403

View file

@ -190,18 +190,11 @@
$string = trim(substr($string, $no1+1, $no2-$no1-1)); $string = trim(substr($string, $no1+1, $no2-$no1-1));
} }
// 테이블.필드 // (테이블.컬럼) 구조 일때 처리
if(($no1 = strpos($string,'.'))!==false) { preg_match("/((?i)[a-z0-9_-]+)[.]((?i)[a-z0-9_\-\*]+)/", $string, $matches);
$tmpString1 = substr($string, 0, $no1); // table
$tmpString2 = substr($string, $no1+1, strlen($string)-$no1+1); // field
$tmpString1 = trim($tmpString1); if($matches) {
$tmpString2 = trim($tmpString2); $string = $this->addDoubleQuotes($matches[1]).".".$this->addDoubleQuotes($matches[2]);
$tmpString1 = $this->addDoubleQuotes($tmpString1);
if($tmpString2 != "*") $tmpString2 = $this->addDoubleQuotes($tmpString2);
$string = $tmpString1.".".$tmpString2;
} }
else { else {
$string = $this->addDoubleQuotes($string); $string = $this->addDoubleQuotes($string);
@ -221,37 +214,32 @@
$tok = strtok(","); $tok = strtok(",");
} }
foreach($values as $val) { foreach($values as $val1) {
if(($no1 = strpos($val,'.'))!==false) { // (테이블.컬럼) 구조 일때 처리
$tmpString1 = substr($val, 0, $no1); // table preg_match("/((?i)[a-z0-9_-]+)[.]((?i)[a-z0-9_\-\*]+)/", $val1, $matches);
$tmpString2 = substr($val, $no1+1, strlen($val)-$no1+1); // field if($matches) {
$tmpString1 = trim($tmpString1);
$tmpString2 = trim($tmpString2);
$isTable = false; $isTable = false;
foreach($tables as $key => $val) {
if($key == $tmpString1) $isTable = true; foreach($tables as $key2 => $val2) {
if($val == $tmpString1) $isTable = true; if($key2 == $matches[1]) $isTable = true;
if($val2 == $matches[1]) $isTable = true;
} }
if($isTable) { if($isTable) {
$tmpString1 = $this->addDoubleQuotes($tmpString1); $return[] = $this->addDoubleQuotes($matches[1]).".".$this->addDoubleQuotes($matches[2]);
if($tmpString2 != "*") $tmpString2 = $this->addDoubleQuotes($tmpString2);
$return[] = $tmpString1.".".$tmpString2;
} }
else { else {
$return[] = $tmpString1.".".$tmpString2; $return[] = $val1;
} }
} }
else if(!is_numeric($val)) { else if(!is_numeric($val1)) {
if(strpos($val, "'") !== 0) if(strpos($val1, "'") !== 0)
$return[] = "'".$val."'"; $return[] = "'".$val1."'";
else else
$return[] = $val; $return[] = $val1;
} }
else { else {
$return[] = $val; $return[] = $val1;
} }
} }