src/Operations/Delete.php
public static function delete($id, $additionalAttributes, $table, $idAttribute = 'id', $limit = 1)
    {
        //force disable limit because they wont work with postgreqsql
        $limit = null;

        $queryValues = [$id];

        $additional = [];

        foreach ($additionalAttributes as $key => $value) {
            //push to additional
            $additional[] = sprintf(
                'AND "%s"."%s" = ?',
                $table,
                $key
            );
            $queryValues[] = $value;
        }

        $tableName = '';
        if (is_array($table) &&
            isset($table['schema']) &&
            isset($table['table'])) {
            $tableName = '"' . $table['schema'] . '"'
                .'."' . $table['table'] . '"';
        } else {
            $tableName = '"' . $table . '"';
        }

        $query = sprintf(
            'DELETE FROM %s
            WHERE "%s" = ?
              %s
              %s',
            $tableName,
            $idAttribute,
            implode("\n", $additional),
            (
                $limit === null
                ? ''
                : 'LIMIT ' . $limit
            )
        );

        return Database::execute($query, $queryValues);
    }
public static function delete($id, $additionalAttributes, $table, $idAttribute = 'id', $limit = 1)
    {
        //force disable limit because they wont work with postgreqsql
        $limit = null;

        $queryValues = [$id];

        $additional = [];

        foreach ($additionalAttributes as $key => $value) {
            //push to additional
            $additional[] = sprintf(
                'AND "%s"."%s" = ?',
                $table,
                $key
            );
            $queryValues[] = $value;
        }

        $tableName = '';
        if (is_array($table) &&
            isset($table['schema']) &&
            isset($table['table'])) {
            $tableName = '"' . $table['schema'] . '"'
                .'."' . $table['table'] . '"';
        } else {
            $tableName = '"' . $table . '"';
        }

        $query = sprintf(
            'DELETE FROM %s
            WHERE "%s" = ?
              %s
              %s',
            $tableName,
            $idAttribute,
            implode("\n", $additional),
            (
                $limit === null
                ? ''
                : 'LIMIT ' . $limit
            )
        );

        return Database::execute($query, $queryValues);
    }
public static function delete ( $ id , $ additionalAttributes , $ table , $ idAttribute = 'id' , $ limit = 1 ) { //force disable limit because they wont work with postgreqsql $ limit = null ; $ queryValues = [ $ id ] ; $ additional = [ ] ; foreach ( $ additionalAttributes as $ key => $ value ) { //push to additional $ additional [ ] = sprintf ( 'AND "%s"."%s" = ?' , $ table , $ key ) ; $ queryValues [ ] = $ value ; } $ tableName = '' ; if ( is_array ( $ table ) && isset ( $ table [ 'schema' ] ) && isset ( $ table [ 'table' ] ) ) { $ tableName = '"' . $ table [ 'schema' ] . '"' . '."' . $ table [ 'table' ] . '"' ; } else { $ tableName = '"' . $ table . '"' ; } $ query = sprintf ( 'DELETE FROM %s
            WHERE "%s" = ?
              %s
              %s' , $ tableName , $ idAttribute , implode ( "\n" , $ additional ) , ( $ limit === null ? '' : 'LIMIT ' . $ limit ) ) ; return Database :: execute ( $ query , $ queryValues ) ; }
Delete database records
@param  string|integer $id
Id value
@param  array|object   $additionalAttributes
Additional attributes to use in WHERE $idAttribute
@param  string|array   $table                Table's name
@param  string         $idAttribute          **[Optional]**
Id attribute
@param  null|integer   $limit                **[Optional]**
Limit clause, when null there is not limit.
@return integer Return number of affected records
Delete database records