delete Back | Forward | Home

'Language Reference'

User Functions

Database Functions

Data Manipulation Functions
  • select

  • insert

  • update

  • delete

  • execute


  • Table Functions

    Error Handling Functions

    << Last Section ( update ) delete Next Section ( execute ) >>
    Usage int delete ( array( 'table' => $table, $where => $where, [, 'limit' => $limit [, 'db' => $db]] ) )
    Purpose To delete rows from a txtSQL table
    Availability txtSQL >= 2.2.2 RC2

    This function will delete any rows that fit the $where clause, and returns the number of rows deleted from the table. This function will only delete rows as long as they are within the $limit. If no $limit is defined, then all rows that match will be deleted.

    Important- To achieve the same results as this function before txtSQL 2.2.2 RC2, use the execute() function
    Note- For more information on defining a where clause, see the how to create a where clause section, or for defining a limit clause, see how to create a limit clause section
    Note- If no $db is specified and no database is already selected, txtSQL will issue an error

    Example 18: delete() Copy to Clipboard
    <?php
    $deleted
    =
    $sql->delete(array('db'     => 'testDB',
                       
    'table'  => 'testTable',
                       
    'where'  => array('id <= 294'),
                       
    'limit'  => array(10, 19)));

    echo
    'txtSQL deleted '.$deleted.' number of row(s)';
    ?>

    User-Contributed Comments for:
    delete()
    Faraz Ali <SaiyanM at hotmail dot com>
    July 30, 2004, 11:19 pm
    If you don't specify a 'where' clause in the query, then all rows will be deleted.
    <?php
    $sql
    ->delete(array('db'    => 'testDB',
                       
    'table' => 'testTable')); // all rows will be deleted
    ?>