public function delete($key = '', $and = true, $tablePrefix = null)
{
is_null($tablePrefix) && ($tablePrefix = $this->tablePrefix);
$tableName = $condition = '';
empty($key) || (list($tableName, $condition) = $this->parseKey($key, $and, true, true));
$tableName = empty($tableName) ? $this->getRealTableName(key($this->table)) : $tablePrefix . $tableName;
if (empty($tableName)) {
throw new \InvalidArgumentException(Lang::get('_PARSE_SQL_ERROR_NO_TABLE_', 'delete'));
}
$whereCondition = $this->sql['where'];
$whereCondition .= empty($condition) ? '' : (empty($whereCondition) ? 'WHERE ' : '') . $condition;
if (empty($whereCondition)) {
throw new \InvalidArgumentException(Lang::get('_PARSE_SQL_ERROR_NO_CONDITION_', 'delete'));
}
$stmt = $this->prepare("DELETE FROM {$tableName} {$whereCondition}", $this->wlink);
$this->execute($stmt);
$this->setCacheVer($tableName);
return $stmt->rowCount();
}