/** * Get / allocate / reserve a new id for the current sequence. Important: Getting the next id will fail in case * no such sequence exists. Make sure to create one if needed, see {@link create()}. * * @return int * @throws Exception */ public function getNextId() { $sql = 'UPDATE ' . $this->table . ' SET value = LAST_INSERT_ID(value + 1) WHERE name = ?'; $result = $this->db->query($sql, array($this->name)); $rowCount = $result->rowCount(); if (1 !== $rowCount) { throw new Exception("Sequence '" . $this->name . "' not found."); } $createdId = $this->db->lastInsertId(); return (int) $createdId; }
public function delete() { $this->initDbIfNeeded(); $table = $this->getTableName(); $sql = "DELETE FROM {$table} WHERE `plugin_name` = ? and `user_login` = ?"; $bind = array($this->pluginName, $this->userLogin); $this->db->query($sql, $bind); }
public function delete() { $this->initDbIfNeeded(); $table = $this->getTableName(); $sql = "DELETE FROM {$table} WHERE `idsite` = ? and plugin_name = ?"; $bind = array($this->idSite, $this->pluginName); $this->db->query($sql, $bind); }