我在php install.php文件中遇到了问题 不能使用MysqlResultSet类型的对象 我不知道为什么我的代码不能正常工作
这是我的代码
$this->provider->executeQuery('INSERT INTO perfect SET type="kings", name="%s", email="%s", points="%s", p_date="%s"',
array($get_players['name'], $get_players['email'], 0, date('Y.m.d'))
);
任何想法?
答案 0 :(得分:0)
完整代码是
public function _isperfect()
{
// attackers
$count_attackers = 0;
$attackers_points = 0;
$attackers = $this->provider->fetchResultSet( "SELECT points FROM perfect WHERE type='attackers' ORDER BY points DESC LIMIT 3");
while ( $attackers->next( ) )
{
$attackers_points = $attackers->row['points'];
$count_attackers++;
}
if($count_attackers < 3)
{
$attackers_points = 0;
}
$get_players = $this->provider->fetchResultSet('SELECT name, email, attack_points FROM p_players WHERE attack_points > %s', array($attackers_points));
while ( $get_players->next( ) )
{
$get_att = $this->provider->fetchRow("SELECT points FROM perfect WHERE type='attackers' && email='". $get_players->row['email'] ."'");
if($get_att != NULL && $get_att['points'] < $get_players->row['attack_points'])
{
$this->provider->executeQuery('DELETE FROM perfect WHERE type="attackers" && email="'. $get_players->row['email'] .'"');
}
if($get_att['points'] < $get_players->row['attack_points'] || $get_att == null)
{
$this->provider->executeQuery('INSERT INTO perfect SET type="attackers", name="%s", email="%s", points="%s", p_date="%s"',
array($get_players->row['name'], $get_players->row['email'], $get_players->row['attack_points'], date('Y.m.d'))
);
}
}
$att = 0;
$attack = $this->provider->fetchResultSet( "SELECT points FROM perfect WHERE type='attackers' ORDER BY points DESC LIMIT 3");
while ( $attack->next( ) )
{
$att = $attack->row['points'];
}
$this->provider->executeQuery('DELETE FROM perfect WHERE points < %s && type="attackers"', array($att));
// end attackers
// defenders
$count_defenders = 0;
$defenders_points = 0;
$defenders = $this->provider->fetchResultSet( "SELECT points FROM perfect WHERE type='defenders' ORDER BY points DESC LIMIT 3");
while ( $defenders->next( ) )
{
$defenders_points = $defenders->row['points'];
$defenders_points++;
}
if($count_defenders < 3)
{
$defenders_points = 0;
}
$get_players = $this->provider->fetchResultSet('SELECT name, email, defense_points FROM p_players WHERE defense_points > %s', array($defenders_points));
while ( $get_players->next( ) )
{
$get_def = $this->provider->fetchRow("SELECT points FROM perfect WHERE type='defenders' && email='". $get_players->row['email'] ."'");
if($get_def != NULL && $get_def['points'] < $get_players->row['defense_points'])
{
$this->provider->executeQuery('DELETE FROM perfect WHERE type="defenders" && email="'. $get_players->row['email'] .'"');
}
if($get_def['points'] < $get_players->row['defense_points'] || $get_def == null)
{
$this->provider->executeQuery('INSERT INTO perfect SET type="defenders", name="%s", email="%s", points="%s", p_date="%s"',
array($get_players->row['name'], $get_players->row['email'], $get_players->row['defense_points'], date('Y.m.d'))
);
}
}
$def = 0;
$defend = $this->provider->fetchResultSet( "SELECT points FROM perfect WHERE type='defenders' ORDER BY points DESC LIMIT 3");
while ( $defend->next( ) )
{
$def = $defend->row['points'];
}
$this->provider->executeQuery('DELETE FROM perfect WHERE points < %s && type="defenders"', array($def));
// end defenders
// empires
$count_empires = 0;
$empires_points = 0;
$empires = $this->provider->fetchResultSet( "SELECT points FROM perfect WHERE type='empires' ORDER BY points DESC LIMIT 3");
while ( $empires->next( ) )
{
$empires_points = $empires->row['points'];
$count_empires++;
}
if($count_empires < 3)
{
$empires_points = 0;
}
$get_players = $this->provider->fetchResultSet('SELECT name, email, total_people_count FROM p_players WHERE total_people_count > %s', array($empires_points));
while ( $get_players->next( ) )
{
$get_emp = $this->provider->fetchRow("SELECT points FROM perfect WHERE type='empires' && email='". $get_players->row['email'] ."'");
if($get_emp != NULL && $get_emp['points'] < $get_players->row['total_people_count'])
{
$this->provider->executeQuery('DELETE FROM perfect WHERE type="empires" && email="'. $get_players->row['email'] .'"');
}
if($get_emp['points'] < $get_players->row['total_people_count'] || $get_emp == null)
{
$this->provider->executeQuery('INSERT INTO perfect SET type="empires", name="%s", email="%s", points="%s", p_date="%s"',
array($get_players->row['name'], $get_players->row['email'], $get_players->row['total_people_count'], date('Y.m.d'))
);
}
}
$emp = 0;
$empir = $this->provider->fetchResultSet( "SELECT points FROM perfect WHERE type='empires' ORDER BY points DESC LIMIT 3");
while ( $empir->next( ) )
{
$emp = $empir->row['points'];
}
$this->provider->executeQuery('DELETE FROM perfect WHERE points < %s && type="empires"', array($emp));
// end empires
// looters
$count_looters = 0;
$looters_points = 0;
$looters = $this->provider->fetchResultSet( "SELECT points FROM perfect WHERE type='looters' ORDER BY points DESC LIMIT 3");
while ( $looters->next( ) )
{
$looters_points = $looters->row['points'];
$count_looters++;
}
if($count_looters < 3)
{
$looters_points = 0;
}
$get_players = $this->provider->fetchResultSet('SELECT name, email, thief_points FROM p_players WHERE thief_points > %s', array($looters_points));
while ( $get_players->next( ) )
{
$get_loo = $this->provider->fetchRow("SELECT points FROM perfect WHERE type='looters' && email='". $get_players->row['email'] ."'");
if($get_loo != NULL && $get_loo['points'] < $get_players->row['thief_points'])
{
$this->provider->executeQuery('DELETE FROM perfect WHERE type="looters" && email="'. $get_players->row['email'] .'"');
}
if($get_loo['points'] < $get_players->row['thief_points'] || $get_loo == null)
{
$this->provider->executeQuery('INSERT INTO perfect SET type="looters", name="%s", email="%s", points="%s", p_date="%s"',
array($get_players->row['name'], $get_players->row['email'], $get_players->row['thief_points'], date('Y.m.d'))
);
}
}
$loo = 0;
$loote = $this->provider->fetchResultSet( "SELECT points FROM perfect WHERE type='looters' ORDER BY points DESC LIMIT 3");
while ( $loote->next( ) )
{
$loo = $loote->row['points'];
}
$this->provider->executeQuery('DELETE FROM perfect WHERE points < %s && type="looters"', array($loo));
// end looters
// kings
$end_server = $this->provider->fetchRow( "SELECT win_pid, game_over FROM `g_settings`");
$end_server_player = $this->provider->fetchRow( 'SELECT `name`,`email` FROM `p_players` WHERE id='.$end_server['win_pid'].' ');
if($end_server_player != null)
{
$this->provider->executeQuery('INSERT INTO perfect SET type="kings", name="%s", email="%s", points="%s", p_date="%s"',
array($get_players['name'], $get_players['email'], 0, date('Y.m.d'))
);
}
}