static function checkCelularHomologado($ua) { include_once $_SERVER['DOCUMENT_ROOT'] . "/../lib/conexion.php"; $conn = new coneXion("MCM"); $db = $conn->db; $oCache = new SQLCache("wap_homologados"); $err_type = 0; //Chequeamos si el celular est� o no ingresado en la base del MCM $sql = "SELECT pk_fk_celulares_modelos_wurfl\r\n\t\t\t\tFROM MCM.celulares_ua_wurfl\r\n\t\t\t\tWHERE pk_descripcion = '{$ua}'"; $row = $oCache->doSelect($sql, 60); //cacheamos los resultados por 30 segundos /*$rs = mysql_query($sql, $db); $row = mysql_fetch_assoc($rs);*/ $id_celular_wurfl = $row[0]['pk_fk_celulares_modelos_wurfl']; if ($id_celular_wurfl > 0) { //si est�, chequeamos si est� o no asociado a la base Web.celulares $sql = "SELECT fk_celulares_web\r\n\t\t\t\t\tFROM MCM.celulares_modelos_wurfl\r\n\t\t\t\t\tWHERE pk_celulares_modelos_wurfl = '{$id_celular_wurfl}'"; $row = $oCache->doSelect($sql, 60); /* $rs = mysql_query($sql, $db); $row = mysql_fetch_assoc($rs); */ $id_celular_web = $row[0]['fk_celulares_web']; if ($id_celular_web == 0) { $err_type = ERR_CELULAR_NO_ASOCIADO; } } else { $err_type = ERR_CELULAR_NO_INGRESADO; } if ($err_type != 0) { $sql = "SELECT count(pk_ua) as cont\r\n\t\t\t\t\tFROM wap_misc.celulares_no_homologados\r\n\t\t\t\t\tWHERE pk_ua = '{$ua}'"; $row = $oCache->doSelect($sql, 60); /* $rs = mysql_query($sql, $db); $row = mysql_fetch_assoc($rs); */ if ($row[0]['cont'] == 0) { //Si ya no ingresamos este UA lo insertamos $sql = "INSERT INTO wap_misc.celulares_no_homologados\r\n\t\t\t\t\t\t(pk_ua, fecha, hora, err_type)\r\n\t\t\t\t\t\tVALUES\r\n\t\t\t\t\t\t('{$ua}', CURDATE(), CURTIME(), '" . $err_type . "')"; mysql_query($sql, $db); include_once $_SERVER['DOCUMENT_ROOT'] . "/../lib/email.class.php"; $msg = "Nuevo celular encontrado, UA:: " . $ua; if ($err_type == ERR_CELULAR_NO_ASOCIADO) { $msg .= "<br/>Descripcion:: El celular est� ingresado, falta asociarlo a Web.contenidos"; } else { $msg .= "<br/>Descripcion:: Hay que ingresar el celular en las tablas del MCM"; } $oMail = new Email("WapMan", "*****@*****.**", "*****@*****.**", "Celular no homologado encontrado", $msg, $msg); $oMail->send(); } } mysql_close($db); }
public function test_SQLCache_Insert(){ $c = new SQLCache(); $result = "this is a sample result"; $o_result = "other result"; $t_result = "third result"; $sql = "SELECT * FROM avalanche_buddy WHERE 1"; $other = "SELECT * FROM avalanche_buddy WHERE billy = 'yourmom'"; $third = "SELECT * FROM avalanche_third WHERE 1"; $insert = "INSERT INTO avalanche_buddy (`asf`) VALUES ('asdf')"; $this->assertEqual(SQLCache::getTableName($sql), "avalanche_buddy", "the table is correct"); $this->assertEqual(SQLCache::getTableName($insert), "avalanche_buddy", "the table is correct"); $c->put($sql, $result); $c->put($other, $o_result); $c->put($third, $t_result); $c->clear($insert); $this->assertEqual($c->get($sql), false, "the result is correct"); $this->assertEqual($c->get($other), false, "the result is correct"); $this->assertEqual($c->get($third), $t_result, "the result is correct"); }