本文整理汇总了PHP中Conexion::query方法的典型用法代码示例。如果您正苦于以下问题:PHP Conexion::query方法的具体用法?PHP Conexion::query怎么用?PHP Conexion::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Conexion
的用法示例。
在下文中一共展示了Conexion::query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dbsave
function dbsave()
{
$db = new Conexion();
if (!empty($this->id)) {
$update = "UPDATE `" . $this->tabla . "` SET ";
$arrayCampos = array();
foreach ($this->campos as $c => $nombre) {
$arrayCampos[] = "`" . $c . "` = '" . $this->{$c} . "'";
}
$update .= implode(', ', $arrayCampos);
$update .= " WHERE id = '" . $this->id . "'";
$db->query($update);
return $this->id;
} else {
$insert = "INSERT INTO `" . $this->tabla . "`\n\t\t \t\t\t\t\tVALUES(";
$arrayCampos = array();
foreach ($this->campos as $c => $nombre) {
if ($c != 'id') {
$arrayCampos[] = "'" . $this->{$c} . "'";
} else {
$arrayCampos[] = '0';
}
}
$insert .= implode(', ', $arrayCampos);
$insert .= ");";
$db->query($insert);
return $db->insertId();
}
}
示例2: Users
function Users()
{
$db = new Conexion();
$query = $db->query("SELECT timer FROM config WHERE id='1' LIMIT 1;");
$timer = $db->recorrer($query)[0];
$db->liberar($query);
$sql = $db->query("SELECT * FROM users;");
$usuarios_actuales = $db->rows($sql);
if (!isset($_SESSION['cantidad_usuarios'])) {
$_SESSION['cantidad_usuarios'] = $usuarios_actuales;
}
if ($_SESSION['cantidad_usuarios'] != $usuarios_actuales or time() - 60 <= $timer) {
while ($d = $db->recorrer($sql)) {
$users[$d['id']] = $d;
}
} else {
if (!isset($_SESSION['users'])) {
while ($d = $db->recorrer($sql)) {
$users[$d['id']] = $d;
}
} else {
$users = $_SESSION['users'];
}
}
$_SESSION['users'] = $users;
$db->liberar($sql);
$db->close();
return $_SESSION['users'];
}
示例3: Entrar
public function Entrar()
{
$this->user = $_SESSION['user'];
$this->id = $_SESSION['id'];
$this->status = $_SESSION['estado'];
$db = new Conexion();
$sqle = "SELECT * FROM user WHERE user='{$this->user}' and id ='{$this->id}' and status = '{$this->status}'";
$result = $db->query($sqle);
$sqle = "UPDATE user SET status='1'";
$result = $db->query($sqle);
$sqle = "SELECT * FROM user WHERE user='{$this->user}' and id ='{$this->id}'";
$result = $db->query($sqle);
$datos = $db->recorrer($result);
$_SESSION['status'] = $datos['status'];
}
示例4: Login
public function Login()
{
try {
if (!empty($_POST['user']) and !empty($_POST['pass']) and !empty($_POST['session'])) {
$db = new Conexion();
$this->user = $db->real_escape_string($_POST['user']);
$this->pass = $db->real_escape_string($_POST['pass']);
//encriptar el login
$sql = $db->query("SELECT * FROM usuarios WHERE user = '{$this->user}' AND pass = '{$this->pass}' ");
if ($db->rows($sql) > 0) {
$datos = $db->recorrer($sql);
$_SESSION['user'] = $datos['user'];
$_SESSION['email'] = $datos['email'];
$_SESSION['id'] = $datos['id'];
if ($_POST['session'] == true) {
ini_set('session.cookie.lifetime', time() + 60 * 60 * 24 * 2);
}
echo 1;
} else {
throw new Exception(2);
}
$db->liberar($sql);
$db->close();
} else {
throw new Exception('Error: Datos vacios.');
}
} catch (Exception $login) {
echo $login->getMessage();
}
}
示例5: Registrar
public function Registrar()
{
try {
if (!empty($_POST['user']) and !empty($_POST['pass']) and !empty('email')) {
$bd = new Conexion();
$this->user = $bd->real_escape_string($_POST['user']);
$this->email = $bd->real_escape_string($_POST['email']);
$this->pass = $this->Encrypt($_POST['pass']);
$sql = $bd->query("SELECT * FROM USUARIOS WHERE user='{$this->user}' OR email = '{$this->email}';");
if ($bd->rows($sql) == 0) {
$online = time() + 60 * 5;
$sql2 = $bd->query("INSERT INTO usuarios(user, pass, email, online)\n VALUES ('{$this->user}','{$this->pass}','{$this->email}', '{$online}');");
$sql3 = $bd->query("SELECT MAX(id) AS id FROM USUARIOS;");
$id = $bd->recorrer($sql3);
$_SESSION['id'] = $id[0];
$_SESSION['user'] = $this->user;
$_SESSION['email'] = $this->email;
$_SESSION['fecha'] = '';
$_SESSION['nombre'] = '';
$_SESSION['apellido'] = '';
$_SESSION['cambio'] = 0;
$_SESSION['ext'] = 'jpg';
$_SESSION['online'] = $online;
echo 1;
$bd->liberar($sql2, $sql3);
} else {
$datos = $bd->recorrer($sql);
if (strtolower($this->user) == strtolower($datos['user'])) {
throw new Exception(2);
} else {
throw new Exception(3);
}
}
$bd->liberar($sql);
$bd->close();
} else {
throw new Exception('Error: Datos Vacios.');
}
} catch (Exception $reg) {
echo $reg->getMessage();
}
}
示例6: Fechatrabajo
public function Fechatrabajo()
{
$db = new Conexion();
$query = "INSERT INTO fecha_trabajo (usuario_idusuario,fecha) \nVALUES ('{$this->idusuario}','{$this->fecha}')\nON DUPLICATE KEY UPDATE fecha='{$this->fecha}'";
$result = $db->query($query);
if ($result) {
echo "<script>\nwindow.location='/admin-control-de-fabricacion/pages/creacion-de-reporte';\n</script>";
} else {
echo "<script>\nalert('HA OCURRIDO UN ERROR');\nwindow.location='/admin-control-de-fabricacion/home';\n</script>";
}
$db->close();
}
示例7: citas
public function citas()
{
$template = new Smarty();
$db = new Conexion();
$sql = $db->query("SELECT * FROM alertas WHERE Activada=-1 and Fecha date_add(NOW(),INTERVAL 1 MONTH) ORDER BY Fecha ASC;");
if ($db->rows($sql) > 0) {
while ($x = $db->recorrer($sql)) {
$citas[] = array('id' => $x['Id'], 'fecha' => $x['Fecha'], 'alerta' => $x['Alerta']);
}
$template->assign('citas', $citas);
}
$template->assign('principal/citas.tpl');
}
示例8: eliminarAvisosViejos
public function eliminarAvisosViejos()
{
$fecha = date('Y-m-j');
$nuevafecha = strtotime('-1 day', strtotime($fecha));
$nuevafecha = date('Y-m-j', $nuevafecha);
try {
$db = new Conexion();
$db->query("delete from avisos where fecha <'{$nuevafecha}'");
return 'success2';
} catch (Exception $exc) {
return 'error';
}
}
示例9: Registrar
public function Registrar()
{
try {
if (!empty($_POST['user']) and !empty($_POST['pass']) and !empty($_POST['email'])) {
$db = new Conexion();
$this->user = $db->real_escape_string($_POST['user']);
$this->email = $db->real_escape_string($_POST['email']);
$this->pass = $this->Encrypt($_POST['pass']);
$sql = $db->query("SELECT * FROM users\n WHERE user='{$this->user}' OR email='{$this->email}';");
if ($db->rows($sql) == 0) {
$sqlTwo = $db->query("INSERT INTO users (user, pass, email)\n VALUES ('{$this->user}', '{$this->pass}', '{$this->email}');");
$id = $db->insert_id;
$_SESSION['id'] = $id;
$_SESSION['user'] = $this->user;
$_SESSION['email'] = $this->email;
$_SESSION['first_name'] = '';
$_SESSION['last_name'] = '';
$_SESSION['date'] = '';
$_SESSION['changes'] = 0;
echo 1;
$db->liberar($sqlTwo);
} else {
$datos = $db->recorrer($sql);
if (strtolower($this->user) == strtolower($datos['user'])) {
throw new Exception(2);
} else {
throw new Exception(3);
}
}
$db->liberar($sql);
$db->close();
} else {
throw new Exception('ERROR: Datos vacios.');
}
} catch (Exception $e) {
echo $e->getMessage();
}
}
示例10: ListaCursos
function ListaCursos()
{
$db = new Conexion();
$sql = $db->query("SELECT * FROM cursos;");
if ($db->rows($sql) > 0) {
while ($d = $db->recorrer($sql)) {
$cursos[$d['id_curso']] = array('id_curso' => $d['id_curso'], 'ficha' => $d['ficha'], 'nombre' => $d['nombre'], 'descripcion' => $d['descripcion'], 'reg_curso' => $d['reg_curso']);
}
} else {
$cursos = false;
}
$db->liberar($sql);
$db->close();
return $cursos;
}
示例11: Users
function Users()
{
$db = new Conexion();
$sql = $db->query("SELECT * FROM user ;");
if ($db->rows($sql) > 0) {
while ($d = $db->recorrer($sql)) {
$users[$d['id_user']] = array('id_user' => $d['id_user'], 'names' => $d['names'], 'last_names' => $d['last_names'], 'email' => $d['email'], 'password' => $d['password'], 'gender' => $d['gender'], 'permisos' => $d['permisos'], 'phone' => $d['phone'], 'cel_phone' => $d['cel_phone'], 'address' => $d['address'], 'names_country' => $d['names_country']);
}
} else {
$users = false;
}
$db->liberar($sql);
$db->close();
return $users;
}
示例12: ListaPais
function ListaPais()
{
$db = new Conexion();
$sql = $db->query("SELECT * FROM country ;");
if ($db->rows($sql) > 0) {
while ($d = $db->recorrer($sql)) {
$pais[$d['id_country']] = array('id_country' => $d['id_country'], 'names_country' => $d['names_country']);
}
} else {
$pais = false;
}
$db->liberar($sql);
$db->close();
return $pais;
}
示例13: Foros
function Foros()
{
$db = new Conexion();
$sql = $db->query("SELECT * FROM foros;");
if ($db->rows($sql) > 0) {
while ($d = $db->recorrer($sql)) {
$foros[$d['id']] = array('id' => $d['id'], 'nombre' => $d['nombre'], 'descrip' => $d['descrip'], 'cantidad_mensajes' => $d['cantidad_mensajes'], 'cantidad_temas' => $d['cantidad_temas'], 'id_categoria' => $d['id_categoria'], 'estado' => $d['estado']);
}
} else {
$foros = false;
}
$db->liberar($sql);
$db->close();
return $foros;
}
示例14: Categorias
function Categorias()
{
$db = new Conexion();
$sql = $db->query("SELECT * FROM categorias;");
if ($db->rows($sql) > 0) {
while ($data = $db->recorrer($sql)) {
$categorias[$data['id']] = $data;
}
} else {
$categorias = false;
}
$db->liberar($sql);
$db->close();
return $categorias;
}
示例15: Users
function Users()
{
$db = new Conexion();
$sql = $db->query("SELECT * FROM users;");
if ($db->rows($sql) > 0) {
while ($d = $db->recorrer($sql)) {
$users[$d['id']] = array('id' => $d['id'], 'user' => $d['user'], 'pass' => $d['pass'], 'email' => $d['email'], 'permisos' => $d['permisos']);
}
} else {
$users = false;
}
$db->liberar($sql);
$db->close();
return $users;
}