rows = array();
$this->pages = array();
$this->url = $_SERVER['PHP_SELF'];
$this->fld = "*";
$this->where = "1=1";
$this->query = array();
$this->page = 1;
$this->orderby = "1";
$this->viewnum = $GLOBALS['_varsBaseCode']['line_num']?:10;
$this->rownum = $GLOBALS['_varsBaseCode']['page_num']?:10;
$this->linktype = "";
}
public function getCommonList($tb="",$prt=false){//테이블, 필드, where절, order by절, 메인url, urlquery, 현재페이지, 목록수, 페이지수
if( $tb ){
$sql = "select count(*) from {$tb} where {$this->where}";
//if( $prt ) echo $sql;
$this->allcnt = $this->DB->queryFirstField($sql,$this->whererow,array(),$prt);
}
$pobj = new Pagenation();
$pgobj = $pobj->get_pagenation($this->allcnt, $this->viewnum, $this->rownum, $this->page);
$this->pagenation = $pgobj;
$this->line_cnt = $pgobj->total_rows - $this->viewnum*($pgobj->current - 1);
$this->pages = $this->getPages($pgobj);
if( $tb ){
//$sql = "select {$this->fld} from {$tb} where {$this->where} order by {$this->orderby} ". $this->DB->_limit($pgobj->limit[0],$pgobj->limit[1]);
$sql = $this->DB->addLimit("select {$this->fld} from {$tb} where {$this->where}",$this->orderby,$pgobj->limit[0],$pgobj->limit[1]);
$this->rows = $this->DB->query( $sql, $this->whererow );
if( !$this->rows ){
$this->rows = Array();
}
}
}
public function getCount($tb,$prt=false){//테이블, 필드, where절, order by절, 메인url, urlquery, 현재페이지, 목록수, 페이지수
$sql = "select count(*) from {$tb} where {$this->where}";
//if( $prt ) echo $sql;
$allcnt = $this->DB->queryFirstField($sql, $this->whererow,array(),$prt);
return $allcnt;
}
private function getHref( $url ){
if( $this->linktype == "script" ){
return 'href="###" onclick="common_page_move(\''.$url.'\')"';
}else{
return 'href='.$url;
}
}
private function getPages($pgobj){
$pagehtml = array();
$query = $this->getQuery($this->query);
if( $pgobj->pages[0] && $pgobj->pages[0] != 1 ){
$pagehtml[] = "getHref("{$this->url}?{$query}&page=1").">[<";
$pagehtml[] = "getHref("{$this->url}?{$query}&page={$pgobj->bprev}")."><";
}
for( $a=0 ; $apages) ; $a++ ){
if( $pgobj->current == $pgobj->pages[$a] ){
$pagehtml[] = "getHref("{$this->url}?{$query}&page={$pgobj->pages[$a]}").">{$pgobj->pages[$a]}";
}else{
$pagehtml[] = "getHref("{$this->url}?{$query}&page={$pgobj->pages[$a]}").">{$pgobj->pages[$a]}";
}
}
if( $pgobj->pages[count($pgobj->pages)-1] != $pgobj->last ){
$pagehtml[] = "getHref("{$this->url}?{$query}&page={$pgobj->bnext}").">>";
$pagehtml[] = "getHref("{$this->url}?{$query}&page={$pgobj->last}").">>]";
}
return $pagehtml;
}
private function getQuery($qrow, $field="",$value=""){
if( $field ){
$qrow[$field] = $value;
}
$query = array();
if( count($qrow) > 0 ){
foreach( $qrow as $key => $val ){
if( hasval($val) ){
$query[] = "{$key}={$val}";
}
}
}
return implode("&", $query);
}
public function getUrl( $chgrow ){ //기존 query 에 $chgrow 부분을 변경/적용하여 url 가져오기
$qrow = $this->query;
if( count($chgrow) > 0 ){
foreach( $chgrow as $key => $val ){
$qrow[$key] = $val;
}
}
return $this->url."?".$this->getQuery($qrow);
}
public function getOrdUrl($field,$oasc=""){ //기존 query에 order용 변경/적용할 부분을 간소화
$oasc = $oasc?:($this->query['oasc']=="asc"?"desc":"asc");
return $this->getUrl(array("ofld"=>$field,"oasc"=>$oasc,"page"=>1));
}
public function getEcptUrl($fields){ //기존 query 에 $fields 부분을 제외하고 url 가져오기
$qrow = $this->query;
if( count($qrow) > 0 ){
foreach( $qrow as $key => $val ){
if( is_array($fields) ){
if( in_array($key, $fields) ) unset($qrow[$key]);
}else{
if( $key == $fields ) unset($qrow[$key]);
}
}
}
return $this->url."?".$this->getQuery($qrow);
}
public function getSearchUrl(){ //기존 query에 정렬부분만 남기고 초기화 하여 url 가져오기
$qrow = $this->query;
if( count($qrow) > 0 ){
foreach( $qrow as $key => $val ){
if( $key != "ofld" && $key != "oasc" ) unset($qrow[$key]);
}
}
return $this->url."?".$this->getQuery($qrow);
}
public function getOrdQueryRow($field,$oasc=""){ //기존 query에 order용 변경/적용할 부분을 간소화하여 배열로 리턴
$oasc = $oasc?:($this->query['oasc']=="asc"?"desc":"asc");
return array("ofld"=>$field,"oasc"=>$oasc,"page"=>1);
}
public function getEcptQueryRow($fields){ //기존 query 에 $fields 부분을 제외하고 배열로 리턴
$qrow = $this->query;
if( count($qrow) > 0 ){
foreach( $qrow as $key => $val ){
if( is_array($fields) ){
if( in_array($key, $fields) ) unset($qrow[$key]);
}else{
if( $key == $fields ) unset($qrow[$key]);
}
}
}
return $qrow;
}
public function getSearchQueryRow(){ //기존 query에 정렬부분만 남기고 초기화 하여 배열로 리턴
$qrow = $this->query;
if( count($qrow) > 0 ){
foreach( $qrow as $key => $val ){
if( $key != "ofld" && $key != "oasc" ) unset($qrow[$key]);
}
}
return $qrow;
}
}