Ejemplo n.º 1
0
    public function deleteKeys($keys)
    {
        $key_str = implode(', ', $keys);
        $sql = <<<SQL
DELETE FROM
    translations_engine
WHERE
    key
IN
    ({$key_str})
SQL;
        try {
            $this->writer->query($sql);
        } catch (\Exception $e) {
            throw new \RuntimeException($e->getMessage(), $e->getCode(), $e);
        }
        return true;
    }
Ejemplo n.º 2
0
    /**
     * Delete an object by id from database
     * @param int $int object identifier
     * @return boolean
     */
    public function deleteById($id)
    {
        $this->validateTableAndIdentityColumn();
        // If the soft delete is activated
        if ($this->deleteColumnName) {
            $query = <<<EOQ
UPDATE {$this->getTableName()}
SET {$this->deleteColumnName} = 1
WHERE {$this->escapeCharacter}{$this->identityColumn}{$this->escapeCharacter} = %s
EOQ;
        } else {
            $query = <<<EOQ
DELETE FROM {$this->getTableName()}
WHERE {$this->escapeCharacter}{$this->identityColumn}{$this->escapeCharacter} = %s
EOQ;
        }
        $params = array('identity' => $id);
        return (bool) $this->db->query($query, $params);
    }