Location: PHPKode > projects > Simple Way to Usenet > libs/core/pgen/engine/page_xml.class.php
<?php

class page_db extends dbobject {
	

	public function __construct($cnf='site_pages'){ parent::__construct($cnf); }
	
	public function exists($pid){
		$arg=Array('id'=>$pid );
		return $this->dbquery($arg, __FUNCTION__);
	}
	
	public function pidby_namelvl($name, $lvl){
		$arg=Array('title'=>$name, 'depth'=>$lvl );
		while( FALSE !== ($r = $this->dbquery($arg, __FUNCTION__, 'pid')) ){
			$o[] = $r;
		}
		if ( isset($o) ){ return $o; }
		return FALSE;
	}
	
	public function get_infobypid($info, $pid){
		$arg=Array('field'=>$info, 'id'=>$pid );
		return $this->dbquery($arg, __FUNCTION__, $info);
	}
		

	
	public function get_childs($pid){
		$arg=Array('id'=>$pid );
		while( FALSE !== ($r = $this->dbquery($arg, __FUNCTION__, 'pid')) ){
			$o[] = $r;
		}
		if ( isset($o) ){ return $o; }
		return FALSE;
	}
	
	public function got_childpage($pid){
		$arg=Array('id'=>$pid );
		return $this->dbquery($arg, __FUNCTION__);
	}
	
	public function listall(){
		$arg=Array();
		return $this->dbquery($arg, __FUNCTION__, 'pid');
	}
	
}	
	
	//----------------------
/**	
	public function isactivequeued($rid, $rpc){
		$q = sprintf("SELECT COUNT(*) FROM %s WHERE `%s`='%s' AND ( `%s`='3' OR `%s`='4' ) AND `%s`='%s'",
                     $this->table,
					$this->struct['rid'], $rid,
					 $this->struct['state'], 					 $this->struct['state'],
 					 $this->struct['qref'], $this->Qref
			);
		$r = $this->getonerow($q);
		if ( CORE::isError($r) ){ return FALSE;} //+raise
		if ( isset($r['COUNT(*)']) ){ return $r['COUNT(*)']; }
		return FALSE;
	}
	
	
	
	public function set_status($rid, $rpc, $stat){
		$q = sprintf("UPDATE `%s` SET `%s`='%s' WHERE `%s`='%s' AND `%s`='%s' AND `%s`='%s'",
						$this->table,
		 				self::$struct['state'], $stat,
						self::$struct['rid'], $rid,
					 	self::$struct['RPCRef'], $rpc,
 					 	self::$struct['qref'], $this->Qref
			);
		$r = $this->update($q);
		if ( CORE::isError($r) ){ return FALSE;} //+raise
		return TRUE;
	}
	
	public function unset_order($rid, $rpc){
		$q = sprintf("UPDATE `%s` SET `%s`=NULL WHERE `%s`='%s' AND `%s`='%s' AND `%s`='%s'",
						$this->table,
		 				self::$struct['order'],
						self::$struct['rid'], $rid,
					 	self::$struct['RPCRef'], $rpc,
 					 	self::$struct['qref'], $this->Qref
			);
		$r = $this->update($q);
		if ( CORE::isError($r) ){ return FALSE;} //+raise
		return TRUE;
	}
	
	public function set_order($rid, $rpc, $order){
		$q = sprintf("UPDATE `%s` SET `%s`='%s' WHERE `%s`='%s' AND `%s`='%s' AND `%s`='%s'",
						$this->table,
		 				self::$struct['order'], $order,
						self::$struct['rid'], $rid,
					 	self::$struct['RPCRef'], $rpc,
 					 	self::$struct['qref'], $this->Qref
			);
		$r = $this->update($q);
		if ( CORE::isError($r) ){ return FALSE;} //+raise
		return TRUE;
	}
	
	public function enqueue($rid, $RPCRef, $order, $state){
		$q = sprintf("INSERT INTO `%s` (`%s`,`%s`,`%s`,`%s`, `%s`) VALUES ('%s', '%s', '%s', '%s', '%s')",
                     	$this->table,
		 				self::$struct['rid'],
		 				self::$struct['RPCRef'],
		 				self::$struct['order'],
		 				self::$struct['qref'],
		 				self::$struct['state'],
						$rid,
 					 	$RPCRef,
 					 	$order,
 					 	$this->Qref,
 					 	$state
			);
		$r = $this->insert($q);
		if ( CORE::isError($r) ){ return FALSE;} //+raise
		//if ( isset($r[self::$struct['state']]) ){ return $r[self::$struct['state']]; }
		return TRUE;
	}

	public function fetchqueue(){
		$q = sprintf("SELECT * FROM %s WHERE `%s`='%s' ORDER BY `%s` ASC,'%s' DESC",
                     $this->table,
 					 self::$struct['qref'], $this->Qref,
					self::$struct['order'], self::$struct['state']
			);
		$r = $this->fetchrow($q);
		if ( CORE::isError($r) ){
			echo 'ERROR : '.$r->getmsg()."\n";
			return FALSE;
		}
		return $this->replace_keys($r, self::$struct);
	}
	
	public function fetch_ordered(){
		$q = sprintf("SELECT * FROM %s WHERE `%s`='%s' AND `%s`<>'NULL' ORDER BY `%s` ASC",
                    $this->table,
 					self::$struct['qref'], $this->Qref,
					self::$struct['order'],
					self::$struct['order']
			);
		$r = $this->fetchrow($q);
		if ( CORE::isError($r) ){
			echo 'ERROR : '.$r->getmsg()."\n";
			return FALSE;
		}
		return $this->replace_keys($r, self::$struct);
	}
	
	public function fetch_inactive(){
		$q = sprintf("SELECT * FROM %s WHERE `%s`='%s' AND `%s`='-1'",
                    $this->table,
 					self::$struct['qref'], $this->Qref,
					self::$struct['state']
			);
		$r = $this->fetchrow($q);
		if ( CORE::isError($r) ){
			echo 'ERROR : '.$r->getmsg()."\n";
			return FALSE;
		}
		return $this->replace_keys($r, self::$struct);
	}
	
	public function fetch_processed(){
		$q = sprintf("SELECT * FROM %s WHERE `%s`='%s' AND `%s`='5'",
                    $this->table,
 					self::$struct['qref'], $this->Qref,
					self::$struct['state']
			);
		$r = $this->fetchrow($q);
		if ( CORE::isError($r) ){
			echo 'ERROR : '.$r->getmsg()."\n";
			return FALSE;
		}
		return $this->replace_keys($r, self::$struct);
	}
	
	public function fetch_active(){
		$q = sprintf("SELECT * FROM %s WHERE `%s`<>'%s' AND `%s`='%s' ORDER BY `%s`",
                     $this->table,
					 self::$struct['order'], '-1',
 					 self::$struct['qref'], $this->Qref,
					 self::$struct['order'] 					 
			);
		$r = $this->fetchrow($q);
		if ( CORE::isError($r) ){
			echo 'ERROR : '.$r->getmsg()."\n";
			return FALSE;
		}
		return $this->replace_keys($r, self::$struct);
	}
	
	public function get_item($rid, $status, $order){
		$q = sprintf("SELECT * FROM %s WHERE `%s`='%s' AND `%s`='%s'",
                     $this->table,
					 self::$struct['order'], $order,
 					 self::$struct['rid'], $rid,
  					 self::$struct['state'], $status,
 					 self::$struct['qref'], $this->Qref		 
			);
		$r = $this->getonerow($q);
		if ( CORE::isError($r) ){
			echo 'ERROR : '.$r->getmsg()."\n";
			return FALSE;
		}
		return $this->replace_keys($r, self::$struct);
	}
	
	public function get_nextitem($order){
		$q = sprintf("SELECT * FROM %s WHERE `%s`<>'NULL' AND `%s`>'%s' AND `%s`='%s' ORDER BY `%s` ASC LIMIT 1",
                    $this->table,
          			self::$struct['order'],
 					self::$struct['order'], $order,
 					self::$struct['qref'], $this->Qref,
 					self::$struct['order']
			);
		$r = $this->getonerow($q);
		if ( CORE::isError($r) ){
			echo 'ERROR : '.$r->getmsg()."\n";
			return FALSE;
		}
		return $this->replace_keys($r, self::$struct);
	}
	
	public function get_previtem($order){
		$q = sprintf("SELECT * FROM %s WHERE `%s`<>'NULL' AND `%s`<'%s' AND `%s`='%s' ORDER BY `%s` DESC LIMIT 1",
                    $this->table,
          			self::$struct['order'],
 					self::$struct['order'], $order,
 					self::$struct['qref'], $this->Qref,
 					self::$struct['order']
			);
		$r = $this->getonerow($q);
		if ( CORE::isError($r) ){
			echo 'ERROR : '.$r->getmsg()."\n";
			return FALSE;
		}
		return $this->replace_keys($r, self::$struct);
	}
	
	public function get_lastactive(){
		$q = sprintf("SELECT * FROM %s WHERE `%s`<>'NULL' AND `%s`='%s' ORDER BY `%s` DESC LIMIT 1",
                     $this->table,
  					 self::$struct['order'],
 					 self::$struct['qref'], $this->Qref,
 					 self::$struct['order']
			);
		$r = $this->getonerow($q);
		if ( CORE::isError($r) ){
			echo 'ERROR : '.$r->getmsg()."\n";
			return FALSE;
		}
		return $this->replace_keys($r, self::$struct);
	}
	
	public function remove($rid, $rpc){
		$q = sprintf("DELETE FROM %s WHERE `%s`='%s' AND `%s`='%s' AND `%s`='%s'",
                     $this->table,
  					 self::$struct['rid'], $rid,
  					 self::$struct['RPCRef'], $rpc,
 					 self::$struct['qref'], $this->Qref
			);
		$r = $this->delete($q);
		if ( CORE::isError($r) ){
			echo 'ERROR : '.$r->getmsg()."\n";
			return FALSE;
		}
		return TRUE;
	}
	
}
*/
Return current item: Simple Way to Usenet