• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Gesior AAC problem

bufuogar

New Member
Joined
Aug 28, 2009
Messages
8
Reaction score
0
hey, ive got a problem with Gesior2012-TFS-0.3.6_and_0.4_to_rev_3703 AAC. whenever i try to access Highscores or Guilds sections on the page, i receive this error:

Code:
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in E:\xampp\htdocs\classes\databaselist.php on line 105

any solutions?
 
Code:
<?php
if(!defined('INITIALIZED'))
	exit;

class DatabaseList extends DatabaseHandler implements Iterator, Countable
{
	public $data;
	public $iterator = 0;
	public $class;
	public $table;
	public $tables = array();
	public $fields = array();
	public $extraFields = array();
	public $filter;
	public $orders = array();
	public $limit;
	public $offset = 0;

	public function __construct($class = null)
	{
		if($class !== null)
			$this->setClass($class);
	}

	public function load()
	{
		$fieldsArray = array();

		if(count($this->fields) > 0)
			foreach($this->fields as $fieldName)
					$fieldsArray[$fieldName] = $this->getDatabaseHandler()->tableName($this->table) . '.' . $this->getDatabaseHandler()->fieldName($fieldName);

		if(count($this->extraFields) > 0)
			foreach($this->extraFields as $field)
				if(!$field->hasAlias())
					$fieldsArray[] = $this->getDatabaseHandler()->tableName($field->getTable()) . '.' . $this->getDatabaseHandler()->fieldName($field->getName());
				else
					$fieldsArray[] = $this->getDatabaseHandler()->tableName($field->getTable()) . '.' . $this->getDatabaseHandler()->fieldName($field->getName()) . ' AS ' . $this->getDatabaseHandler()->fieldName($field->getAlias());

		$tables = array();
		foreach($this->tables as $table)
			$tables[] = $this->getDatabaseHandler()->tableName($table);

		$filter = '';
		if($this->filter !== null)
			$filter = ' WHERE ' .$this->filter->__toString();

		$order = '';
		$orders = array();
		if(count($this->orders) > 0)
		{
			foreach($this->orders as $_tmp_order)
				$orders[] = $_tmp_order->__toString();
			if(count($orders) > 0)
				$order = ' ORDER BY ' . implode(', ', $orders);
		}

		$limit = '';
		if($this->limit !== null)
			$limit = ' LIMIT ' . (int) $this->limit;

		$offset = '';
		if($this->offset > 0)
			$offset = ' OFFSET ' . (int) $this->offset;

		$query = 'SELECT ' . implode(', ', $fieldsArray) . ' FROM ' . implode(', ', $tables) . $filter . $order . $limit . $offset;

		$this->data = $this->getDatabaseHandler()->query($query)->fetchAll();
	}

	public function getResult($id)
	{
		if(!isset($this->data))
			$this->load();
		if(isset($this->data[$id]))
		{
			if(!is_object($this->data[$id]))
			{
				$_tmp = new $this->class();
				$_tmp->loadData($this->data[$id]);
				return $_tmp;
			}
			else
				return $this->data[$id];
		}
		else
			return false;
	}

	public function addExtraField($field)
	{
		$this->extraFields[] = $field;
		$this->addTables($field->getTable());
	}

	public function addOrder($order)
	{
		$this->orders[] = $order;
	}

	public function setClass($class)
	{
		$this->class = $class;
		$instance = new $this->class();
		$this->fields = $instance::$fields;
		if(isset($instance::$extraFields))
			foreach($instance::$extraFields as $extraField)
			{
				if(!isset($extraField[2]))
					$this->extraFields[] = new SQL_Field($extraField[0], $extraField[1]);
				else
					$this->extraFields[] = new SQL_Field($extraField[0], $extraField[1], $extraField[2]);
				$this->tables[$extraField[1]] = $extraField[1];
			}
		$this->table = $instance::$table;
		$this->tables[$instance::$table] = $instance::$table;
	}

	public function setFilter($filter)
	{
		$this->addTables($filter->getTables());
		$this->filter = $filter;
	}

	public function setLimit($limit)
	{
		$this->limit = $limit;
	}

	public function setOffset($offset)
	{
		$this->offset = $offset;
	}

	public function addTables($tables)
	{
		if(is_array($tables))
		{
			foreach($tables as $table)
				if($table != '' && !in_array($table, $this->tables))
					$this->tables[$table] = $table;
		}
		elseif($tables != '' && !in_array($tables, $this->tables))
			$this->tables[$tables] = $tables;
	}

    public function current()
    {
        return $this->getResult($this->iterator);
    }

    public function rewind()
    {
		if(!isset($this->data))
			$this->load();
        $this->iterator = 0;
    }

    public function next()
    {
        ++$this->iterator;
    }

    public function key()
    {
        return $this->iterator;
    }

    public function valid()
    {
        return isset($this->data[$this->iterator]);
    }

    public function count()
    {
		if(!isset($this->data))
			$this->load();
        return count($this->data);
    }
}

- - - Updated - - -
 
Last edited:
use this:
PHP:
<?php
if(!defined('INITIALIZED'))
exit;

class DatabaseList extends DatabaseHandler implements Iterator, Countable
{
public $data;
public $iterator = 0;
public $class;
public $table;
public $tables = array();
public $fields = array();
public $extraFields = array();
public $filter;
public $orders = array();
public $limit;
public $offset = 0;

public function __construct($class = null)
{
if($class !== null)
$this->setClass($class);
}

public function load()
{
$fieldsArray = array();

if(count($this->fields) > 0)
foreach($this->fields as $fieldName)
$fieldsArray[$fieldName] = $this->getDatabaseHandler()->tableName($this->table) . '.' . $this->getDatabaseHandler()->fieldName($fieldName);

if(count($this->extraFields) > 0)
foreach($this->extraFields as $field)
if(!$field->hasAlias())
$fieldsArray[] = $this->getDatabaseHandler()->tableName($field->getTable()) . '.' . $this->getDatabaseHandler()->fieldName($field->getName());
else
$fieldsArray[] = $this->getDatabaseHandler()->tableName($field->getTable()) . '.' . $this->getDatabaseHandler()->fieldName($field->getName()) . ' AS ' . $this->getDatabaseHandler()->fieldName($field->getAlias());

$tables = array();
foreach($this->tables as $table)
$tables[] = $this->getDatabaseHandler()->tableName($table);

$filter = '';
if($this->filter !== null)
$filter = ' WHERE ' .$this->filter->__toString();

$order = '';
$orders = array();
if(count($this->orders) > 0)
{
foreach($this->orders as $_tmp_order)
$orders[] = $_tmp_order->__toString();
if(count($orders) > 0)
$order = ' ORDER BY ' . implode(', ', $orders);
}

$limit = '';
if($this->limit !== null)
$limit = ' LIMIT ' . (int) $this->limit;

$offset = '';
if($this->offset > 0)
$offset = ' OFFSET ' . (int) $this->offset;

$query = 'SELECT ' . implode(', ', $fieldsArray) . ' FROM ' . implode(', ', $tables) . $filter . $order . $limit . $offset;

$this->data = $this->getDatabaseHandler()->query($query)->fetchAll();
}

public function getResult($id)
{
if(!isset($this->data))
$this->load();
if(isset($this->data[$id]))
{
if(!is_object($this->data[$id]))
{
$_tmp = new $this->class();
$_tmp->loadData($this->data[$id]);
return $_tmp;
}
else
return $this->data[$id];
}
else
return false;
}

public function addExtraField($field)
{
$this->extraFields[] = $field;
$this->addTables($field->getTable());
}

public function addOrder($order)
{
$this->orders[] = $order;
}

public function setClass($class)
{
$this->class = $class;
$instance = new $this->class();
$this->fields = $instance::$fields;
if(isset($instance::$extraFields))
foreach($instance::$extraFields as $extraField)
{
if(!isset($extraField[2]))
$this->extraFields[] = new SQL_Field($extraField[0], $extraField[1]);
else
$this->extraFields[] = new SQL_Field($extraField[0], $extraField[1], $extraField[2]);
$this->tables[$extraField[1]] = $extraField[1];
}
$this->table = $instance::$table;
$this->tables[$instance::$table] = $instance::$table;
}

public function setFilter($filter)
{
$this->addTables($filter->getTables());
$this->filter = $filter;
}

public function setLimit($limit)
{
$this->limit = $limit;
}

public function setOffset($offset)
{
$this->offset = $offset;
}

public function addTables($tables)
{
if(is_array($tables))
{
foreach($tables as $table)
if($table != '' && !in_array($table, $this->tables))
$this->tables[$table] = $table;
}
elseif($tables != '' && !in_array($tables, $this->tables))
$this->tables[$tables] = $tables;
}

    public function current()
    {
        return $this->getResult($this->iterator);
    }

    public function rewind()
    {
if(!isset($this->data))
$this->load();
        $this->iterator = 0;
    }

    public function next()
    {
        ++$this->iterator;
    }

    public function key()
    {
        return $this->iterator;
    }

    public function valid()
    {
        return isset($this->data[$this->iterator]);
    }

    public function count()
    {
if(!isset($this->data))
$this->load();
        return count($this->data);
    }
}

or changed your higthscores but this:
PHP:
<?PHP
$list = $_REQUEST['list'];
$page = $_REQUEST['page'];
switch($list)
{
  case "fist":
   $id = 0;
   $list_name = 'Fist Fighting';
   break;
  case "club":
   $id = 1;
   $list_name = 'Club Fighting';
   break;
  case "sword":
   $id = 2;
   $list_name = 'Sword Fighting';
   break;
  case "axe":
   $id = 3;
   $list_name = 'Axe Fighting';
   break;
  case "distance":
   $id = 4;
   $list_name = 'Distance Fighting';
   break;
  case "shield":
   $id = 5;
   $list_name = 'Shielding';
   break;
  case "fishing":
   $id = 6;
   $list_name = 'Fishing';
   break;
}

if(!isset($id))
{
	if($list == "magic")
		$list_name = "Magic Level";
	else
	{
		$list_name = 'Experience';
		$list = 'experience';
	}
}
	
$world_id = 0;
$world_name = $config['server']['serverName'];

$offset = $page * 100;
if(isset($id))
	$skills = $SQL->query('SELECT name,online,value,level,vocation,promotion FROM players,player_skills WHERE players.world_id = '.$world_id.' AND players.deleted = 0 AND players.group_id < '.$config['site']['players_group_id_block'].' AND players.id = player_skills.player_id AND player_skills.skillid = '.$id.' ORDER BY value DESC, count DESC LIMIT 101 OFFSET '.$offset);
elseif($list == "magic")
	$skills = $SQL->query('SELECT name,online,maglevel,level,vocation,promotion FROM players WHERE players.world_id = '.$world_id.' AND players.deleted = 0 AND players.group_id < '.$config['site']['players_group_id_block'].' AND name != "Account Manager" ORDER BY maglevel DESC, manaspent DESC LIMIT 101 OFFSET '.$offset);
elseif($list == "experience")
	$skills = $SQL->query('SELECT name,online,level,experience,vocation,promotion FROM players WHERE players.world_id = '.$world_id.' AND players.deleted = 0 AND players.group_id < '.$config['site']['players_group_id_block'].' AND name != "Account Manager" ORDER BY level DESC, experience DESC LIMIT 101 OFFSET '.$offset);

	
$main_content .= '<center><h2> Highscores of '.$list_name.' on '.$world_name.'</h2></center><br />';
$main_content .= '
	<div align="center">
	<a href=?subtopic=highscores>Experience</a> | <a href=?subtopic=highscores&list=magic>Magic</a> | <a href=?subtopic=highscores&list=fist>Fist</a> | <a href=?subtopic=highscores&list=club>Club</a> | <a href=?subtopic=highscores&list=sword>Sword</a> | <a href=?subtopic=highscores&list=axe>Axe</a> | <a href=?subtopic=highscores&list=distance>Distance</a> | <a href=?subtopic=highscores&list=shield>Shielding</a> | <a href=?subtopic=highscores&list=fishing>Fishing</a><br /><br />
	<table border="0" cellspacing="1" cellpadding="3" width="85%">
		<tr bgcolor="'.$config['site']['vdarkborder'].'">
			<td width="10%" class="white"> <b><center>#</center></b> </td>
			<td width="50%" class="white"> <b><center>Player Name</center></b> </td>
			<td width="20%" class="white"> <b><center>Level</center></b> </td>';
if($list == "experience")
$main_content .= '
			<td width="20%" class="white"> <b><center>Experience</center></b> </td>';
$main_content .= '
		</tr>';
		foreach($skills as $skill) {
			$player = $ots->createObject('Player');
			$player->find($skill['name']);
			$account = $player->getAccount();
			$ban = '';
			if($account->isBanned())
			$ban = '<font color="darkred"> [Banished]</font>';
			if($number_of_rows < 100) {
				if($list == "magic")
					$skill['value'] = $skill['maglevel'];
				if($list == "experience")
					$skill['value'] = $skill['level'];
				if(!is_int($number_of_rows / 2)) {
					$bgcolor = $config['site']['darkborder'];
				}
				else {
					$bgcolor = $config['site']['lightborder'];
				}
				$number_of_rows++;
$main_content .= '
		<tr bgcolor="'.$bgcolor.'">
			<td><center>'.($offset + $number_of_rows).'. </center></td>
			<td><center> <a href="?subtopic=characters&name='.urlencode($skill['name']).'">'.($skill['online']>0 ? "<font color=\"green\">".$skill['name']."</font>" : "<font color=\"red\">".$skill['name']."</font>").'</a> '.$ban.'<br /><small>'.$skill['level'].' '.$vocation_name[$world_id][$skill['promotion']][$skill['vocation']].'</small> </center></td>
			<td><center> '.$skill['value'].' </center></td>';
if($list == "experience")
$main_content .= '
			<td> <center>'.$skill['experience'].'</center> </td>';
$main_content .= '
		</tr>';
			}
		else
			$show_link_to_next_page = TRUE;
		}
$main_content .= '
	</table></div>';
$main_content .= '
<table border="0" cellspacing="1" width="90%">';
if($page > 0)
$main_content .= '
		<tr>
			<td width="90%" align="left" valign="bottom"><a href="?subtopic=highscores&list='.$list.'&page='.($page - 1).'">Previous Page</a> </td>
		</tr>';
if($show_link_to_next_page)
$main_content .= '		
		<tr>
			<td width="90%" align="right" valign="bottom"><a href="?subtopic=highscores&list='.$list.'&page='.($page + 1).'">Next Page</a> </td>
		</tr>';
$main_content .= '</table>';
?>
 
use this:
PHP:
<?php
if(!defined('INITIALIZED'))
exit;

class DatabaseList extends DatabaseHandler implements Iterator, Countable
{
public $data;
public $iterator = 0;
public $class;
public $table;
public $tables = array();
public $fields = array();
public $extraFields = array();
public $filter;
public $orders = array();
public $limit;
public $offset = 0;

public function __construct($class = null)
{
if($class !== null)
$this->setClass($class);
}

public function load()
{
$fieldsArray = array();

if(count($this->fields) > 0)
foreach($this->fields as $fieldName)
$fieldsArray[$fieldName] = $this->getDatabaseHandler()->tableName($this->table) . '.' . $this->getDatabaseHandler()->fieldName($fieldName);

if(count($this->extraFields) > 0)
foreach($this->extraFields as $field)
if(!$field->hasAlias())
$fieldsArray[] = $this->getDatabaseHandler()->tableName($field->getTable()) . '.' . $this->getDatabaseHandler()->fieldName($field->getName());
else
$fieldsArray[] = $this->getDatabaseHandler()->tableName($field->getTable()) . '.' . $this->getDatabaseHandler()->fieldName($field->getName()) . ' AS ' . $this->getDatabaseHandler()->fieldName($field->getAlias());

$tables = array();
foreach($this->tables as $table)
$tables[] = $this->getDatabaseHandler()->tableName($table);

$filter = '';
if($this->filter !== null)
$filter = ' WHERE ' .$this->filter->__toString();

$order = '';
$orders = array();
if(count($this->orders) > 0)
{
foreach($this->orders as $_tmp_order)
$orders[] = $_tmp_order->__toString();
if(count($orders) > 0)
$order = ' ORDER BY ' . implode(', ', $orders);
}

$limit = '';
if($this->limit !== null)
$limit = ' LIMIT ' . (int) $this->limit;

$offset = '';
if($this->offset > 0)
$offset = ' OFFSET ' . (int) $this->offset;

$query = 'SELECT ' . implode(', ', $fieldsArray) . ' FROM ' . implode(', ', $tables) . $filter . $order . $limit . $offset;

$this->data = $this->getDatabaseHandler()->query($query)->fetchAll();
}

public function getResult($id)
{
if(!isset($this->data))
$this->load();
if(isset($this->data[$id]))
{
if(!is_object($this->data[$id]))
{
$_tmp = new $this->class();
$_tmp->loadData($this->data[$id]);
return $_tmp;
}
else
return $this->data[$id];
}
else
return false;
}

public function addExtraField($field)
{
$this->extraFields[] = $field;
$this->addTables($field->getTable());
}

public function addOrder($order)
{
$this->orders[] = $order;
}

public function setClass($class)
{
$this->class = $class;
$instance = new $this->class();
$this->fields = $instance::$fields;
if(isset($instance::$extraFields))
foreach($instance::$extraFields as $extraField)
{
if(!isset($extraField[2]))
$this->extraFields[] = new SQL_Field($extraField[0], $extraField[1]);
else
$this->extraFields[] = new SQL_Field($extraField[0], $extraField[1], $extraField[2]);
$this->tables[$extraField[1]] = $extraField[1];
}
$this->table = $instance::$table;
$this->tables[$instance::$table] = $instance::$table;
}

public function setFilter($filter)
{
$this->addTables($filter->getTables());
$this->filter = $filter;
}

public function setLimit($limit)
{
$this->limit = $limit;
}

public function setOffset($offset)
{
$this->offset = $offset;
}

public function addTables($tables)
{
if(is_array($tables))
{
foreach($tables as $table)
if($table != '' && !in_array($table, $this->tables))
$this->tables[$table] = $table;
}
elseif($tables != '' && !in_array($tables, $this->tables))
$this->tables[$tables] = $tables;
}

    public function current()
    {
        return $this->getResult($this->iterator);
    }

    public function rewind()
    {
if(!isset($this->data))
$this->load();
        $this->iterator = 0;
    }

    public function next()
    {
        ++$this->iterator;
    }

    public function key()
    {
        return $this->iterator;
    }

    public function valid()
    {
        return isset($this->data[$this->iterator]);
    }

    public function count()
    {
if(!isset($this->data))
$this->load();
        return count($this->data);
    }
}

still the same error
Code:
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in E:\xampp\htdocs\classes\databaselist.php on line 105

or changed your higthscores but this:
PHP:
<?PHP
$list = $_REQUEST['list'];
$page = $_REQUEST['page'];
switch($list)
{
  case "fist":
   $id = 0;
   $list_name = 'Fist Fighting';
   break;
  case "club":
   $id = 1;
   $list_name = 'Club Fighting';
   break;
  case "sword":
   $id = 2;
   $list_name = 'Sword Fighting';
   break;
  case "axe":
   $id = 3;
   $list_name = 'Axe Fighting';
   break;
  case "distance":
   $id = 4;
   $list_name = 'Distance Fighting';
   break;
  case "shield":
   $id = 5;
   $list_name = 'Shielding';
   break;
  case "fishing":
   $id = 6;
   $list_name = 'Fishing';
   break;
}

if(!isset($id))
{
	if($list == "magic")
		$list_name = "Magic Level";
	else
	{
		$list_name = 'Experience';
		$list = 'experience';
	}
}
	
$world_id = 0;
$world_name = $config['server']['serverName'];

$offset = $page * 100;
if(isset($id))
	$skills = $SQL->query('SELECT name,online,value,level,vocation,promotion FROM players,player_skills WHERE players.world_id = '.$world_id.' AND players.deleted = 0 AND players.group_id < '.$config['site']['players_group_id_block'].' AND players.id = player_skills.player_id AND player_skills.skillid = '.$id.' ORDER BY value DESC, count DESC LIMIT 101 OFFSET '.$offset);
elseif($list == "magic")
	$skills = $SQL->query('SELECT name,online,maglevel,level,vocation,promotion FROM players WHERE players.world_id = '.$world_id.' AND players.deleted = 0 AND players.group_id < '.$config['site']['players_group_id_block'].' AND name != "Account Manager" ORDER BY maglevel DESC, manaspent DESC LIMIT 101 OFFSET '.$offset);
elseif($list == "experience")
	$skills = $SQL->query('SELECT name,online,level,experience,vocation,promotion FROM players WHERE players.world_id = '.$world_id.' AND players.deleted = 0 AND players.group_id < '.$config['site']['players_group_id_block'].' AND name != "Account Manager" ORDER BY level DESC, experience DESC LIMIT 101 OFFSET '.$offset);

	
$main_content .= '<center><h2> Highscores of '.$list_name.' on '.$world_name.'</h2></center><br />';
$main_content .= '
	<div align="center">
	<a href=?subtopic=highscores>Experience</a> | <a href=?subtopic=highscores&list=magic>Magic</a> | <a href=?subtopic=highscores&list=fist>Fist</a> | <a href=?subtopic=highscores&list=club>Club</a> | <a href=?subtopic=highscores&list=sword>Sword</a> | <a href=?subtopic=highscores&list=axe>Axe</a> | <a href=?subtopic=highscores&list=distance>Distance</a> | <a href=?subtopic=highscores&list=shield>Shielding</a> | <a href=?subtopic=highscores&list=fishing>Fishing</a><br /><br />
	<table border="0" cellspacing="1" cellpadding="3" width="85%">
		<tr bgcolor="'.$config['site']['vdarkborder'].'">
			<td width="10%" class="white"> <b><center>#</center></b> </td>
			<td width="50%" class="white"> <b><center>Player Name</center></b> </td>
			<td width="20%" class="white"> <b><center>Level</center></b> </td>';
if($list == "experience")
$main_content .= '
			<td width="20%" class="white"> <b><center>Experience</center></b> </td>';
$main_content .= '
		</tr>';
		foreach($skills as $skill) {
			$player = $ots->createObject('Player');
			$player->find($skill['name']);
			$account = $player->getAccount();
			$ban = '';
			if($account->isBanned())
			$ban = '<font color="darkred"> [Banished]</font>';
			if($number_of_rows < 100) {
				if($list == "magic")
					$skill['value'] = $skill['maglevel'];
				if($list == "experience")
					$skill['value'] = $skill['level'];
				if(!is_int($number_of_rows / 2)) {
					$bgcolor = $config['site']['darkborder'];
				}
				else {
					$bgcolor = $config['site']['lightborder'];
				}
				$number_of_rows++;
$main_content .= '
		<tr bgcolor="'.$bgcolor.'">
			<td><center>'.($offset + $number_of_rows).'. </center></td>
			<td><center> <a rel="nofollow" href="?subtopic=characters&name='.urlencode($skill['name']).'">'.($skill['online']>0 ? "<font color=\"green\">".$skill['name']."</font>" : "<font color=\"red\">".$skill['name']."</font>").'</a> '.$ban.'<br /><small>'.$skill['level'].' '.$vocation_name[$world_id][$skill['promotion']][$skill['vocation']].'</small> </center></td>
			<td><center> '.$skill['value'].' </center></td>';
if($list == "experience")
$main_content .= '
			<td> <center>'.$skill['experience'].'</center> </td>';
$main_content .= '
		</tr>';
			}
		else
			$show_link_to_next_page = TRUE;
		}
$main_content .= '
	</table></div>';
$main_content .= '
<table border="0" cellspacing="1" width="90%">';
if($page > 0)
$main_content .= '
		<tr>
			<td width="90%" align="left" valign="bottom"><a rel="nofollow" href="?subtopic=highscores&list='.$list.'&page='.($page - 1).'">Previous Page</a> </td>
		</tr>';
if($show_link_to_next_page)
$main_content .= '		
		<tr>
			<td width="90%" align="right" valign="bottom"><a rel="nofollow" href="?subtopic=highscores&list='.$list.'&page='.($page + 1).'">Next Page</a> </td>
		</tr>';
$main_content .= '</table>';
?>

this one gives another error:
Code:
Fatal error: Call to a member function query() on a non-object in E:\xampp\htdocs\classes\highscores.php on line 56

but i guess it doesn't have anything to do with highscores itself, as the first error refers to highscores, guilds and account management sections
 
PHP:
<?php
if(!defined('INITIALIZED'))
	exit;

class DatabaseList extends DatabaseHandler implements Iterator, Countable
{
	public $data;
	public $iterator = 0;
	public $class;
	public $table;
	public $tables = array();
	public $fields = array();
	public $extraFields = array();
	public $filter;
	public $orders = array();
	public $limit;
	public $offset = 0;

	public function __construct($class = null)
	{
		if($class !== null)
			$this->setClass($class);
	}

	public function load()
	{
		$fieldsArray = array();

		if(count($this->fields) > 0)
			foreach($this->fields as $fieldName)
					$fieldsArray[$fieldName] = $this->getDatabaseHandler()->tableName($this->table) . '.' . $this->getDatabaseHandler()->fieldName($fieldName);

		if(count($this->extraFields) > 0)
			foreach($this->extraFields as $field)
				if(!$field->hasAlias())
					$fieldsArray[] = $this->getDatabaseHandler()->tableName($field->getTable()) . '.' . $this->getDatabaseHandler()->fieldName($field->getName());
				else
					$fieldsArray[] = $this->getDatabaseHandler()->tableName($field->getTable()) . '.' . $this->getDatabaseHandler()->fieldName($field->getName()) . ' AS ' . $this->getDatabaseHandler()->fieldName($field->getAlias());

		$tables = array();
		foreach($this->tables as $table)
			$tables[] = $this->getDatabaseHandler()->tableName($table);

		$filter = '';
		if($this->filter !== null)
			$filter = ' WHERE ' .$this->filter->__toString();

		$order = '';
		$orders = array();
		if(count($this->orders) > 0)
		{
			foreach($this->orders as $_tmp_order)
				$orders[] = $_tmp_order->__toString();
			if(count($orders) > 0)
				$order = ' ORDER BY ' . implode(', ', $orders);
		}

		$limit = '';
		if($this->limit !== null)
			$limit = ' LIMIT ' . (int) $this->limit;

		$offset = '';
		if($this->offset > 0)
			$offset = ' OFFSET ' . (int) $this->offset;

		$query = 'SELECT ' . implode(', ', $fieldsArray) . ' FROM ' . implode(', ', $tables) . $filter . $order . $limit . $offset;

		$this->data = $this->getDatabaseHandler()->query($query)->fetchAll();
	}

	public function getResult($id)
	{
		if(!isset($this->data))
			$this->load();
		if(isset($this->data[$id]))
		{
			if(!is_object($this->data[$id]))
			{
				$_tmp = new $this->class();
				$_tmp->loadData($this->data[$id]);
				return $_tmp;
			}
			else
				return $this->data[$id];
		}
		else
			return false;
	}

	public function addExtraField($field)
	{
		$this->extraFields[] = $field;
		$this->addTables($field->getTable());
	}

	public function addOrder($order)
	{
		$this->orders[] = $order;
	}

	public function setClass($class)
	{
		$this->class = $class;
		$instance = new $this->class();
		$this->fields = $instance::$fields;
		if(isset($instance::$extraFields))
			foreach($instance::$extraFields as $extraField)
			{
				if(!isset($extraField[2]))
					$this->extraFields[] = new SQL_Field($extraField[0], $extraField[1]);
				else
					$this->extraFields[] = new SQL_Field($extraField[0], $extraField[1], $extraField[2]);
				$this->tables[$extraField[1]] = $extraField[1];
			}
		$this->table = $instance::$table;
		$this->tables[$instance::$table] = $instance::$table;
	}

	public function setFilter($filter)
	{
		$this->addTables($filter->getTables());
		$this->filter = $filter;
	}

	public function setLimit($limit)
	{
		$this->limit = $limit;
	}

	public function setOffset($offset)
	{
		$this->offset = $offset;
	}

	public function addTables($tables)
	{
		if(is_array($tables))
		{
			foreach($tables as $table)
				if($table != '' && !in_array($table, $this->tables))
					$this->tables[$table] = $table;
		}
		elseif($tables != '' && !in_array($tables, $this->tables))
			$this->tables[$tables] = $tables;
	}

    public function current()
    {
        return $this->getResult($this->iterator);
    }

    public function rewind()
    {
		if(!isset($this->data))
			$this->load();
        $this->iterator = 0;
    }

    public function next()
    {
        ++$this->iterator;
    }

    public function key()
    {
        return $this->iterator;
    }

    public function valid()
    {
        return isset($this->data[$this->iterator]);
    }

    public function count()
    {
		if(!isset($this->data))
			$this->load();
        return count($this->data);
    }
}


line 105:

PHP:
		$this->addTables($field->getTable());
 
I am actually really not sure. try this..

$this->addTables($field::getTable()); if not the try this..

$this::addTables($field->getTable());

both of these seem to be fine, but still i get another error:
Code:
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in E:\xampp\htdocs\classes\databaselist.php on line 93

line 93:
PHP:
				return $_tmp;
 
solved. it turned out to be the problem with xampp, not the code itself. upgrading to 0.7.3 version helped.

anyway thanks to everyone who tried to help
 
Back
Top