/** * Save Tag * @return bollean */ public function save() { $data = array(self::ID_TAG => $this->getIdTag(), self::TAG => $this->getTag()); $sql = new Sql(); if (is_null($this->getIdTag())) { $sql->insert($data, self::TABLE); $this->idTag = $sql->lastRow(self::TABLE)->id_tag; return true; } else { $pk = array(self::ID_TAG => $this->getIdTag()); return $sql->update($data, self::TABLE, $pk); } }
static function send($pj, $msg) { $pj = Characters::get($pj); if (!$pj['success']) { return array('success' => false, 'msg' => $pj['msg']); } else { $pj = $pj['data']; } PDOSql::$pdobj = pdoConnect(); $iduser = Sql::esc($pj['iduser']); $msg = Sql::esc(str_replace('{%NAME%}', $pj['name'], $msg)); return Sql::insert("INSERT INTO notifications (iduser, msg, status) VALUES ('{$iduser}', '{$msg}', '0')"); }
/** * Save * @return bollean */ public function save() { $data = array(self::ISOLANG => $this->getIsoLang(), self::DEFAULT_CULTURE => $this->getDefault()); $sql = new Sql(); if (!self::hasCulture($this->getIsoLang())) { $sql->insert($data, self::TABLE); $this->isolang = $sql->lastRow(self::TABLE)->isolang; return true; } else { $pk = array(self::ISOLANG => $this->getIsoLang()); return $sql->update($data, self::TABLE, $pk); } }
/** * Save Log * @return bollean */ public function save() { $data = array(self::ID => self::getId(), self::DATE => self::getDate(), self::FILE => self::getFile(), self::MESSAGE => self::getMessage(), self::IS_ERROR => self::getIsError()); $sql = new Sql(); if (is_null($this->getId())) { $sql->insert($data, self::TABLE); $this->id = $sql->lastRow(self::TABLE)->id; return true; } else { $pk = array(self::ID => self::getId()); return $sql->update($data, self::TABLE, $pk); } }
static function insert($table, $data, $connection = 'default') { return static::query(\Sql::insert($table, $data) . ' asd', $connection); }
function action_register($login, $password, $repassword, $mail) { if ($password != $repassword) { $d = array('success' => false, 'error' => 'password and repassword'); } else { if (Sql::count('users', 'pseudo = ?', $login) > 0) { $d = array('success' => false, 'error' => 'login'); } else { if (!filter_var($mail, FILTER_VALIDATE_EMAIL)) { $d = array('success' => false, 'error' => 'incorrect mail'); } else { $data = array('pseudo' => $login, 'password' => $password, 'mail' => $mail); Sql::insert('users', $data); $d = array('success' => true); } } } return json_encode($d); }
static function altaCategoria($data) { if (!self::tieneCatCustom($_SESSION['clientID'])) { self::createCatTbl($_SESSION['clientID']); } $tbl_name = "custom_cats_" . $_SESSION['clientID']; PDOSql::$pdobj = pdoConnect(); $categoria = Sql::esc($data['categoria']); $subcat = Sql::esc($data['subcategoria']); $i = Sql::insert("INSERT INTO {$tbl_name} (categoria, subcategoria) values ('" . $categoria . "', '" . $subcat . "')"); if ($i > 0) { return array('success' => true, 'data' => array(), 'msg' => 'Se creó la categoría personalizada'); } }
/** * Save Tag * @return bollean */ public function save() { $data = array(self::ID_TAG_I18N => $this->getIdTagI18n(), self::ID_TAG => $this->getIdTag(), self::ISOLANG => $this->getIsoLang(), self::TRANSLATE => $this->getTranslate()); $sql = new Sql(); if (is_null($this->getIdTagI18n())) { $sql->insert($data, self::TABLE); $this->idTagI18n = $sql->lastRow(self::TABLE) ? $sql->lastRow(self::TABLE)->id_tag_i18n : ''; $this->idTag = $sql->lastRow(self::TABLE) ? $sql->lastRow(self::TABLE)->id_tag : ''; return true; } else { $pk = array(self::ID_TAG_I18N => $this->getIdTagI18n()); return $sql->update($data, self::TABLE, $pk); } }