mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-09 12:02:24 +09:00
git-svn-id: http://xe-core.googlecode.com/svn/trunk@1106 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
4f1d02cda0
commit
ea50fbbaa6
43 changed files with 235 additions and 101 deletions
|
|
@ -235,6 +235,25 @@
|
|||
return new Object();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 이름, 값, operation, type으로 값을 변경
|
||||
**/
|
||||
function getConditionValue($name, $value, $operation, $type) {
|
||||
if($type == 'number') return (int)$value;
|
||||
|
||||
switch($operation) {
|
||||
case 'like_prefix' :
|
||||
$value = '%'.$value;
|
||||
break;
|
||||
case 'like' :
|
||||
$value = '%'.$value.'%';
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return "'".$this->addQuotes($value)."'";
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 이름, 값, operation으로 조건절 작성
|
||||
**/
|
||||
|
|
@ -260,6 +279,15 @@
|
|||
if(!$value) return;
|
||||
return $name.' < '.$value;
|
||||
break;
|
||||
case 'like_prefix' :
|
||||
case 'like' :
|
||||
if(!$value) return;
|
||||
return $name.' like '.$value;
|
||||
break;
|
||||
case 'in' :
|
||||
if(!$value) return;
|
||||
return $name.' in ('.$value.')';
|
||||
break;
|
||||
case 'notequal' :
|
||||
if(!$value) return;
|
||||
return $name.' != '.$value;
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@
|
|||
$this->is_connected = true;
|
||||
|
||||
// mysql의 경우 utf8임을 지정
|
||||
$this->_query("SET NAMES 'utf8'");
|
||||
$this->_query("set names 'utf8'");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -291,15 +291,18 @@
|
|||
|
||||
foreach($output->conditions as $key => $val) {
|
||||
$sub_condition = '';
|
||||
foreach($val as $k =>$v) {
|
||||
if(!$v->value) continue;
|
||||
$name = $v->column;
|
||||
if($output->column_type[$name]!='number') $value = "'".$this->addQuotes($v->value)."'";
|
||||
else $value = $v->value;
|
||||
$operation = $v->operation;
|
||||
foreach($val['condition'] as $k =>$v) {
|
||||
if(!$v['value']) continue;
|
||||
|
||||
$name = $v['column'];
|
||||
$operation = $v['operation'];
|
||||
$value = $v['value'];
|
||||
$type = $output->column_type[$name];
|
||||
$pipe = $v['pipe'];
|
||||
|
||||
$value = $this->getConditionValue($name, $value, $operation, $type);
|
||||
$str = $this->getConditionPart($name, $value, $operation);
|
||||
if($sub_condition) $sub_condition .= ' '.$v->pipe.' ';
|
||||
if($sub_condition) $sub_condition .= ' '.$pipe.' ';
|
||||
$sub_condition .= $str;
|
||||
}
|
||||
if($sub_condition) {
|
||||
|
|
@ -309,8 +312,7 @@
|
|||
}
|
||||
|
||||
if($condition) $condition = ' where '.$condition;
|
||||
|
||||
return "";
|
||||
return $condition;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -326,8 +328,12 @@
|
|||
foreach($output->columns as $key => $val) {
|
||||
$name = $val['name'];
|
||||
$value = $val['value'];
|
||||
if($output->column_type[$name]!='number') $value = "'".$this->addQuotes($value)."'";
|
||||
if(!$value) $value = 'null';
|
||||
if($output->column_type[$name]!='number') {
|
||||
$value = "'".$this->addQuotes($value)."'";
|
||||
if(!$value) $value = 'null';
|
||||
} else {
|
||||
if(!$value) $value = 0;
|
||||
}
|
||||
|
||||
$column_list[] = '`'.$name.'`';
|
||||
$value_list[] = $value;
|
||||
|
|
@ -393,24 +399,35 @@
|
|||
$table_list[] = '`'.$this->prefix.$key.'` as '.$val;
|
||||
}
|
||||
|
||||
if(!$column) $columns = '*';
|
||||
else {
|
||||
foreach($invert_columns as $key => $val) {
|
||||
if($val) $column_list[] = sprintf('%s as %s',$val, $key);
|
||||
else $column_list[] = sprintf('%s',$val);
|
||||
if(!$output->columns) {
|
||||
$columns = '*';
|
||||
} else {
|
||||
$column_list = array();
|
||||
foreach($output->columns as $key => $val) {
|
||||
$name = $val['name'];
|
||||
$alias = $val['alias'];
|
||||
if($name == '*') {
|
||||
$column_list[] = '*';
|
||||
} elseif(strpos($name,'.')===false && strpos($name,'(')===false) {
|
||||
if($alias) $column_list[] = sprintf('`%s` as `%s`', $name, $alias);
|
||||
else $column_list[] = sprintf('`%s`',$name);
|
||||
} else {
|
||||
if($alias) $column_list[] = sprintf('%s as `%s`', $name, $alias);
|
||||
else $column_list[] = sprintf('%s',$name);
|
||||
}
|
||||
}
|
||||
$columns = implode(',', $column_list);
|
||||
$columns = implode(',',$column_list);
|
||||
}
|
||||
|
||||
$condition = $this->getCondition($output);
|
||||
|
||||
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
||||
|
||||
if($output->list_count) return $this->_getNavigationData($table_list, $columns, $condition, $output);
|
||||
|
||||
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
||||
|
||||
if($output->order) {
|
||||
foreach($output->order as $key => $val) {
|
||||
$index_list[] = sprintf('%s %s', $key, $val);
|
||||
$index_list[] = sprintf('%s %s', $val[0], $val[1]);
|
||||
}
|
||||
if(count($index_list)) $query .= ' order by '.implode(',',$index_list);
|
||||
}
|
||||
|
|
@ -438,24 +455,30 @@
|
|||
$count_output = $this->_fetch($result);
|
||||
$total_count = (int)$count_output->count;
|
||||
|
||||
$list_count = $output->list_count['value'];
|
||||
if(!$list_count) $list_count = 20;
|
||||
$page_count = $output->page_count['value'];
|
||||
if(!$page_count) $page_count = 10;
|
||||
$page = $output->page->value;
|
||||
if(!$page) $page = 1;
|
||||
|
||||
// 전체 페이지를 구함
|
||||
$total_page = (int)(($total_count-1)/$navigation->list_count) +1;
|
||||
$total_page = (int)(($total_count-1)/$list_count) +1;
|
||||
|
||||
// 페이지 변수를 체크
|
||||
if($navigation->page > $total_page) $page = $navigation->page;
|
||||
else $page = $navigation->page;
|
||||
$start_count = ($page-1)*$navigation->list_count;
|
||||
if($page > $total_page) $page = $total_page;
|
||||
$start_count = ($page-1)*$list_count;
|
||||
|
||||
$query = sprintf("select %s from %s %s", implode(',',$columns), implode(',',$table_list), $condition);
|
||||
$query = sprintf("select %s from %s %s", $columns, implode(',',$table_list), $condition);
|
||||
|
||||
if($output->order) {
|
||||
foreach($output->order as $key => $val) {
|
||||
$index_list[] = sprintf('%s %s', $index_obj[0], $index_obj[1]);
|
||||
$index_list[] = sprintf('%s %s', $val[0], $val[1]);
|
||||
}
|
||||
if(count($index_list)) $query .= ' order by '.implode(',',$index_list);
|
||||
}
|
||||
|
||||
$query .= sprintf('%s limit %d, %d', $query, $start_count, $output->list_count['value']);
|
||||
$query = sprintf('%s limit %d, %d', $query, $start_count, $list_count);
|
||||
|
||||
$result = $this->_query($query);
|
||||
if($this->isError()) {
|
||||
|
|
@ -465,11 +488,11 @@
|
|||
$buff->page = 1;
|
||||
$buff->data = array();
|
||||
|
||||
$buff->page_navigation = new PageHandler($total_count, $total_page, $page, $navigation->page_count);
|
||||
$buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count);
|
||||
return $buff;
|
||||
}
|
||||
|
||||
$virtual_no = $total_count - ($page-1)*$navigation->list_count;
|
||||
$virtual_no = $total_count - ($page-1)*$list_count;
|
||||
while($tmp = mysql_fetch_object($result)) {
|
||||
$data[$virtual_no--] = $tmp;
|
||||
}
|
||||
|
|
@ -480,7 +503,7 @@
|
|||
$buff->page = $page;
|
||||
$buff->data = $data;
|
||||
|
||||
$buff->page_navigation = new PageHandler($total_count, $total_page, $page, $navigation->page_count);
|
||||
$buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count);
|
||||
return $buff;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -165,13 +165,14 @@
|
|||
$buff .= '$output->columns = array ( ';
|
||||
foreach($output->columns as $key => $val) {
|
||||
$val['default'] = $this->getDefault($val['name'], $val['default']);
|
||||
if($val['var']) {
|
||||
$buff .= sprintf('array("name"=>"%s", "value"=>$args->%s?$args->%s:%s),%s', $val['name'], $val['var'], $val['var'], $val['default'] ,"\n");
|
||||
if($val['var'] && strpos($val['var'],'.')===false) {
|
||||
$buff .= sprintf('array("name"=>"%s", "alias"=>"%s", "value"=>$args->%s?$args->%s:%s),%s', $val['name'], $val['alias'], $val['var'], $val['var'], $val['default'] ,"\n");
|
||||
if($val['default']) $default_list[$val['var']] = $val['default'];
|
||||
if($val['notnull']) $notnull_list[] = $val['var'];
|
||||
if($val['minlength']) $minlength_list[$val['var']] = $val['minlength'];
|
||||
if($val['maxlength']) $maxlength_list[$val['var']] = $val['maxlength'];
|
||||
} else {
|
||||
$buff .= sprintf('array("name"=>"%s", "value"=>%s),%s', $val['name'], $val['default'] ,"\n");
|
||||
$buff .= sprintf('array("name"=>"%s", "alias"=>"%s", "value"=>%s),%s', $val['name'], $val['alias'], $val['default'] ,"\n");
|
||||
}
|
||||
}
|
||||
$buff .= ' );'."\n";
|
||||
|
|
@ -186,13 +187,14 @@
|
|||
$v->default = $this->getDefault($v->column, $v->default);
|
||||
if($v->var) {
|
||||
if(strpos($v->var,".")===false) {
|
||||
if($v->default) $default_list[$v->var] = $v->default;
|
||||
if($v->filter) $filter_list[] = $v;
|
||||
$buff .= sprintf('array("column"=>"%s", "value"=>$args->%s?$args->%s:%s,"pipe"=>"%s","operation"=>"%s",),%s', $v->column, $v->var, $v->var, $v->default, $v->pipe, $v->operation, "\n");
|
||||
} else {
|
||||
$buff .= sprintf('array("column"=>"%s", "value"=>"%s","pipe"=>"%s","operation"=>"%s",),%s', $v->column, $v->var, $v->pipe, $v->operation, "\n");
|
||||
}
|
||||
} else {
|
||||
$buff .= sprintf('array("name"=>"%s", "value"=>%s,"pipe"=>"%s","operation"=>"%s",),%s', $v->name, $v->default ,$v->pipe, $v->operation,"\n");
|
||||
$buff .= sprintf('array("column"=>"%s", "value"=>%s,"pipe"=>"%s","operation"=>"%s",),%s', $v->column, $v->default ,$v->pipe, $v->operation,"\n");
|
||||
}
|
||||
}
|
||||
$buff .= ')),'."\n";
|
||||
|
|
@ -205,7 +207,7 @@
|
|||
if($output->order) {
|
||||
$buff .= '$output->order = array(';
|
||||
foreach($output->order as $key => $val) {
|
||||
$buff .= sprintf('"%s"=>"%s",', $val->var, $val->order);
|
||||
$buff .= sprintf('array($args->%s?$args->%s:"%s","%s"),', $val->var, $val->var, $val->default, $val->order);
|
||||
}
|
||||
$buff .= ');'."\n";
|
||||
}
|
||||
|
|
@ -225,31 +227,38 @@
|
|||
$buff .= sprintf('$output->page = array("var"=>"%s", "value"=>$args->%s?$args->%s:"%s");%s', $output->page->var, $output->page->var, $output->page->var, $output->list->default,"\n");
|
||||
}
|
||||
|
||||
// default check
|
||||
if(count($default_list)) {
|
||||
foreach($default_list as $key => $val) {
|
||||
$pre_buff .= 'if(!isset($args->'.$key.')) $args->'.$key.' = '.$val.';'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
// not null check
|
||||
if(count($notnull_list)) {
|
||||
foreach($notnull_list as $key => $val) {
|
||||
$pre_buff .= 'if(!$args->'.$val.') return new Object(-1, sprintf($lang->filter->isnull, $lang->'.$val.'?$lang->'.$val.':\''.$val.'\'));'."\n";
|
||||
$pre_buff .= 'if(!isset($args->'.$val.')) return new Object(-1, sprintf($lang->filter->isnull, $lang->'.$val.'?$lang->'.$val.':\''.$val.'\'));'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
// minlength check
|
||||
if(count($minlength_list)) {
|
||||
foreach($minlength_list as $key => $val) {
|
||||
$pre_buff .= 'if(strlen($args->'.$key.')<'.$val.') return new Object(-1, sprintf($lang->filter->outofrange, $lang->'.$key.'?$lang->'.$key.':\''.$key.'\'));'."\n";
|
||||
$pre_buff .= 'if($args->'.$key.'&&strlen($args->'.$key.')<'.$val.') return new Object(-1, sprintf($lang->filter->outofrange, $lang->'.$key.'?$lang->'.$key.':\''.$key.'\'));'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
// maxlength check
|
||||
if(count($maxlength_list)) {
|
||||
foreach($maxlength_list as $key => $val) {
|
||||
$pre_buff .= 'if(strlen($args->'.$key.')>'.$val.') return new Object(-1, sprintf($lang->filter->outofrange, $lang->'.$key.'?$lang->'.$key.':\''.$key.'\'));'."\n";
|
||||
$pre_buff .= 'if($args->'.$key.'&&strlen($args->'.$key.')>'.$val.') return new Object(-1, sprintf($lang->filter->outofrange, $lang->'.$key.'?$lang->'.$key.':\''.$key.'\'));'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
// filter check
|
||||
if(count($filter_list)) {
|
||||
foreach($filter_list as $key => $val) {
|
||||
$pre_buff .= sprintf('unset($output); $output = $this->_checkFilter("%s",$args->%s,"%s"); if(!$output->toBool()) return $output;%s',$val->var,$val->var,$val->filter,"\n");
|
||||
$pre_buff .= sprintf('unset($_output); $_output = $this->_checkFilter("%s",$args->%s,"%s"); if(!$_output->toBool()) return $_output;%s',$val->var,$val->var,$val->filter,"\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -276,7 +285,7 @@
|
|||
|
||||
switch($func_name) {
|
||||
case 'ipaddress' :
|
||||
$val = '"$_SERVER[\'REMOTE_ADDR\']"';
|
||||
$val = '$_SERVER[\'REMOTE_ADDR\']';
|
||||
break;
|
||||
case 'unixtime' :
|
||||
$val = 'time()';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue