Prepare a query to delete data from database.

@param $params array array();
'table' Names of table
'db_name' => Database name
'wheres' Specify a selection criteria to get required records

@return bool
168723
public function delete($params)
    {
        $query = $this->query->delete($params);
        $this->db->exec($this->query->useQuery($params['db_name']));
        $prepare = $this->db->prepare($query);
        if ($prepare->execute()) {
            $prepare->closeCursor();

            return true;
        }
    }
93212
public function delete ($params = FALSE, &$db = FALSE)
	{
		
		// Get database master for write

		if ($db === FALSE)
		{
			$db	=& $this->getDbMaster ();
		}
		
		// If there is no key value passed set to the object id
		
		if ($params === FALSE)
		{
			$params	= array (
				'where' => array (
					array (static::$pk, $this->iget (static::$pk))
				)
			);
		}
		
		// If the params are not an array assume the variable
		// is an object pk, and set the parameter array
		
		if (!is_array ($params))
		{
			$params	= array (
				'where' => array (
					array (static::$pk, $params)
				)
			);
		}
		
		// If there is no where clause
		
		if (!isset ($params['where']))
		{
			throw new Exception ('No where clause for ' . get_called_class () . '->delete');
		}
		
		// Changelog
		
		$arrRemove	= FALSE;
		
		// Get all objects being removed
		
		if ($this->changelog ('delete'))
		{
			$arrRemove	= static::_getObjects (array ('where' => $params['where']), FALSE, $db);
		}
		
		// Prepare query
		
		$query = $db->prepare ('
			DELETE FROM `' . static::$dbTable . '` 
			' . $db->genClause ('WHERE', $db->genWHERE ($params['where']))
		);
		
		// Bind values
		
		$db->genBindValues ($query, $params['where']);
		
		// Execute

		$query->execute ();
		
		// Changelog
		
		if ($arrRemove)
		{
			
			$log =& $this->getResource ('changelog');
			$log->hookTransactions ($db);
			
			// Log all removed entries
			
			foreach ($arrRemove as $obj)
			{
				$log::_Log ('delete', $obj);
			}
			
		}

		// return TRUE

		return TRUE;
		
	}
418784
public function queryRow($params = array())
    {
        $this->mergeParams($params);
        $this->beginQuery();
        $rst = $this->statement->fetch(\PDO::FETCH_ASSOC);
        $this->statement->closeCursor();
        return $rst;
    }
1355354
public function delete(): bool
    {
        if (! $this->exists())
        {
            return false;
        }

        $sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE ' . $this->getKeyName() . ' = :key';
        $query = DB::getConnection()->prepare($sql);

        return $query->execute(['key' => $this->getKey()]);
    }
824429
function deleteWhere($table_name, $where_with_placeholders, $named_parameters) {

            if (empty($where_with_placeholders) || !$table_name) {
                return false;
            }

            $sql_query = 'DELETE FROM ' . $table_name . ' WHERE ' . $where_with_placeholders;

            Event::dispatch(EventData::forBefore(Event::BEFORE_DELETE, $table_name, $named_parameters, $sql_query));
            try {
                //Run Delete query, collect stats
                $stmt = $this->db_connection->prepare($sql_query);
                if (!empty($named_parameters)) {
                    foreach ($named_parameters as $k => $v) {
                        $stmt->bindValue($k, $v);
                    }
                }

                $stmt->execute();
            } catch (Exception $ex) {
                Event::dispatch(EventData::forException($ex, $sql_query, $named_parameters));

                throw new QueryException($ex->getMessage(), $ex->getCode(), $ex);
            }

            $rows_affected = $stmt->rowCount();
            Event::dispatch(EventData::forAfter(Event::AFTER_DELETE, $table_name, $named_parameters, $sql_query, $rows_affected));

            return $rows_affected;

        }
658504
protected function prepareParams(array $params)
    {
        foreach ($params as $key => $param) {
            if (gettype($param) === 'boolean') {
                $params[$key] = (string)(($param) ? 'true' : 'false');
            }
        }
        return $params;
    }
1120140
protected function query($query, ...$params)
    {
        $saveParams = array_map([$this, 'quote'], $params);

        $baseSql = str_replace('{table}', $this->table, $query);
        $sql = vsprintf($baseSql, $saveParams);

        $ret = $this->server->query($sql);

        if ($ret === false) {
            trigger_error($this->server->error . " $sql", E_USER_NOTICE);
        }

        return $ret;
    }
163611
protected function prepareParams($params)
    {
        if (isset($params['dsn'])) {
            $params['dsn'] = str_replace('oracle:', 'oci:', $params['dsn']);
        }

        return parent::prepareParams($params);
    }
1139385
public function deleteBy($conditions = [])
    {
        if (count($conditions)) {
            if (method_exists($this, 'beforeDelete')) {
                $this->beforeDelete();
            }

            if (method_exists($this, 'beforeDelete')) {
                $this->beforeDelete();
            }

            if ($this->qb->table($this->table)->limit(1)->delete($conditions)) {
                if (method_exists($this, 'afterDelete')) {
                    return $this->afterDelete();
                }

                return $this->db->getAffectedRows();
            }
        }

        return false;
    }
1361195
public static function _genQuery ($params, &$db = FALSE)
	{
		
		// Set select

		if (!isset ($params['select']))
		{
			$params['select']	= '*';
		}
		
		// Set from

		if (!isset ($params['from']))
		{
			$params['from']		= '`' . static::$dbTable . '`';
		}
		
		// Get database slave for read

		if ($db === FALSE)
		{
			$db	=& self::_getDbSlave ();
		}
		
		if (!($db instanceof \PDO))
		{
			throw new Exception ('Invalid or no database resource set');
		}
		
		// Return value

		return $db->genQuery ($params);
		
	}
1208944
public static function containsParams(...$params): bool
    {
        $params = array_flip(is_array($params[0]) ? $params[0] : $params);

        foreach (static::getAllParameters() as $name => $value) {
            if (array_key_exists($name, $params)) {
                unset($params[$name]);
            }
        }

        return count($params) == 0;
    }
1276598
private function formatSqlByParams(array $params)
    {
        if (empty($params)) {
            return;
        }
        foreach ($params as $key => $value) {
            $this->sql .= " $key=" . $value;
        }
    }
920985
final public function delete() {
	
		if (!$this->getId()) return FALSE;
		
		// trigger a custom function before deletion
		$this->beforeDelete();
		
		$class = get_called_class();
		
		// build the SQL where line
		$where = ' WHERE ' . implode(' AND ', $this->getSqlKeyConditions());
		
		$query = 'DELETE FROM `' . $class::TABLE_NAME . '`' . $where . ' LIMIT 1';
		$res = $this->db->exec($query, $this->getSqlKeyValues());
		
		// list properties to not remove
		$activeRecordsProperties = array('db', 'loadedFromDb', 'typeList', 'errors');
		
		// unset all properties
		foreach ($this as $key => $value) {
			if (!in_array($key, $activeRecordsProperties)) {
				unset($this->$key);
			}
		}
		
		$this->loadedFromDb = FALSE;
		
		// trigger a custom function after deletion
		$this->afterDelete();

		return (bool)$res;
		
	}
531907
public function insert($params)
    {
        $query = $this->query->insert($params);
        $prepare = $this->db->prepare($query);
        if ($prepare->execute()) {
            $last = $this->db->lastInsertId();
            $prepare->closeCursor();

            return $last;
        } else {
            return false;
        }
    }
420754
public function sqlFetch(string $sql, array $params = []): ?array
    {
        return $this->prepare($sql, $params)->fetch(\PDO::FETCH_ASSOC);
    }
321066
public function query($sql = null,$params = array())
	{
		if(!isset($this->operationOption['params']))
		{
			$this->operationOption['params'] = array();
		}
		$this->prepareQuery($sql ? $sql : $this->buildSelectSQL(),$params);
		if(false === $this->lastStmt)
		{
			return false;
		}
		else
		{
			return $this->lastStmt->fetchAll(PDO::FETCH_ASSOC);
		}
	}
640701
public function sqlDelete(
		$from,
		$where,
		array $where_params,
		$limit = null
	) {
		$sql = $this->queryBuilder->buildDelete($from, $where, $limit);
		$query = $this->database->prepare($sql);
		$query->execute($where_params);
		$this->addQuery($query->queryString, $where_params);
		return $query->rowCount();
	}