Example #1
0
/**
 * Used to delete data from database
 * 
 * @since 1.2.2
 * @param array $connection_information an array with following keys:
 * host => the database host name
 * user => the database user
 * password => the database password
 * database => the database name
 * debug => the debug level it can be 0,1 or 2
 * charset => utf8
 */
function DeleteQuery($connection_information)
{
    /** The database connection details */
    $parameters = $connection_information;
    /** The DatabaseFunctions object is created */
    $database = new DatabaseFunctions($parameters);
    /** The database table name */
    $table_name = "pakphp_cached_data";
    /** The table name is set */
    $database->df_set_table($table_name);
    /** The where clause */
    $where_clause = array();
    /** The field name in where clause */
    $where_clause[0]['field'] = "function_name";
    /** The field value */
    $where_clause[0]['value'] = "InsertQuery";
    /** The operation. e.g =,<,>,!= */
    $where_clause[0]['operation'] = "=";
    /** The operator. e.g AND, OR, NOT */
    $where_clause[0]['operator'] = "";
    /** The database query is fetched */
    $query = $database->df_build_query(array(), $where_clause, 'd');
    echo "<h3>Database query: </h3>";
    /** The query is displayed */
    echo $query;
    /** The database query is run */
    $database->df_execute($query);
    /** The number of rows affected by the query */
    $affected_rows = $database->df_affected_rows($query);
    echo "<h3>Affected rows: </h3>";
    print_r($affected_rows);
    /** The query log is displayed */
    echo "<h3>Query Log: </h3>";
    $database->df_display_query_log(false);
    /** The query log is cleared */
    $database->df_clear_query_log();
    /** The database connection is closed */
    $database->df_close();
}