本文整理汇总了PHP中Connect::rows方法的典型用法代码示例。如果您正苦于以下问题:PHP Connect::rows方法的具体用法?PHP Connect::rows怎么用?PHP Connect::rows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connect
的用法示例。
在下文中一共展示了Connect::rows方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Register
public function Register()
{
try {
if ($_POST['user'] and $_POST['pass'] and $_POST['email']) {
$db = new Connect();
$this->user = $db->real_escape_string($_POST['user']);
$this->email = $db->real_escape_string($_POST['email']);
$this->pass = sha1($_POST['pass']);
$sql = $db->query("SELECT usuario,email FROM usuarios \n WHERE usuario='{$this->user}' OR email='{$this->email}' LIMIT 1;");
if ($db->rows($sql) == 0) {
$sql2 = $db->query("SELECT COUNT(id) FROM usuarios LIMIT 1;");
$top = $db->recorrer($sql2);
$top = $top[0] + 1;
$sql3 = $db->query("INSERT INTO usuarios (usuario,password,email,faccion,top) \n VALUES ('{$this->user}','{$this->pass}','{$this->email}','1','{$top}');");
$sql4 = $db->query("SELECT MAX(id) AS id FROM usuarios LIMIT 1;");
$id = $db->recorrer($sql4);
$id = $id[0];
$db->liberar($sql, $sql2, $sql3, $sql4);
require 'core/models/class.GeneratePlanet.php';
$planeta = new GeneratePlanet();
$planeta->RegisterPlanet($id);
$planet = $db->query("SELECT id_planeta FROM planetas WHERE id_dueno='{$id}' LIMIT 1;");
$id_planet = $db->recorrer($planet);
$id_planet = $id_planet[0];
$_SESSION['id_planet'] = $id_planet;
$_SESSION['user'] = $this->user;
$_SESSION['id'] = $id;
unset($sql, $sql2, $sql3, $sql4, $top, $db, $id, $this->email, $this->pass);
echo 1;
$db->liberar($planet);
$db->close();
} else {
$dato = $db->recorrer($sql);
$db->liberar($sql);
$db->close();
$lng = new Lang();
if (strtolower($dato[1]) == strtolower($this->email) and strtolower($dato[0]) != strtolower($this->user)) {
throw new Exception($lng->e_email_existe);
} else {
if (strtolower($dato[1]) != strtolower($this->email) and strtolower($dato[0]) == strtolower($this->user)) {
throw new Exception($lng->e_user_existe);
} else {
throw new Exception($lng->e_user_email_existe);
}
}
unset($sql, $db, $lng, $dato, $this->user, $this->email, $this->pass);
}
} else {
throw new Exception('error');
}
} catch (Exception $e) {
echo $e->getMessage();
}
exit;
}
示例2: Register
public function Register()
{
if (!empty($_POST['user']) and !empty($_POST['pass']) and !empty($_POST['email'])) {
$db = new Connect();
$this->user = $db->real_escape_string($_POST['user']);
$this->email = $db->real_escape_string($_POST['email']);
$this->pass = sha1($_POST['pass']);
$sql = $db->query("SELECT usuario,email FROM usuarios \n WHERE usuario='{$this->user}' OR email='{$this->email}' LIMIT 1;");
if ($db->rows($sql) == 0) {
$sql2 = $db->query("SELECT COUNT(id) FROM usuarios LIMIT 1;");
$top = $db->recorrer($sql2);
$top = $top[0] + 1;
$sql3 = $db->query("INSERT INTO usuarios (usuario,password,email,faccion,top) \n VALUES ('{$this->user}','{$this->pass}','{$this->email}','1','{$top}');");
$sql4 = $db->query("SELECT MAX(id) AS id FROM usuarios LIMIT 1;");
$id = $db->recorrer($sql4);
$id = $id[0];
$db->liberar($sql, $sql2, $sql3, $sql4);
require 'core/models/class.GeneratePlanet.php';
$planeta = new GeneratePlanet();
$planeta->RegisterPlanet($id);
$planet = $db->query("SELECT id_planeta FROM planetas WHERE id_dueno='{$id}' LIMIT 1;");
$id_planet = $db->recorrer($planet);
$id_planet = $id_planet[0];
$_SESSION['id_planet'] = $id_planet;
$_SESSION['user'] = $this->user;
$_SESSION['id'] = $id;
$login = '<script>window.location="?core=overview";</script>';
$db->liberar($planet);
$db->close();
unset($sql, $sql2, $sql3, $sql4, $top, $db, $id, $this->email, $this->pass);
} else {
$dato = $db->recorrer($sql);
$db->liberar($sql);
$db->close();
$lng = new Lang();
if (strtolower($dato[1]) == strtolower($this->email) and strtolower($dato[0]) != strtolower($this->user)) {
$login = $lng->e_email_existe;
} else {
if (strtolower($dato[1]) != strtolower($this->email) and strtolower($dato[0]) == strtolower($this->user)) {
$login = $lng->e_user_existe;
} else {
$login = $lng->e_user_email_existe;
}
}
unset($sql, $db, $lng, $dato, $this->user, $this->email, $this->pass);
}
} else {
$lng = new Lang();
$login = $lng->e_datos_vac;
unset($lng);
}
echo $login;
unset($login);
}