Skip to content

setOrder

Ayoob edited this page Apr 11, 2020 · 2 revisions

setOrder

[easySQLite3 >= v0.1.0 (Beta)]

Set the order for querying/updating/deleting records of the database.

setOrder

setOrder( string $column_name [, boolean $is_desc = false ] ) : string

This function is used to set the order of records when querying/updating/deleting records of the database.

The order will be saved in the class to be used automatically when querying/updating/deleting records of the database, or the return value of this function can be passed to the showRecords(), updateRecords(), or deleteRecords() functions to querying/updating/deleting records of the database.

Parameters

Parameter Description
column_name Name of column you want to set the order for.
is_desc Setting this to true will make the order descending order, otherwise it will be ascending order.

Return Values

The function returns a string containing the order.

If column_name is not specified, the function will return false.

Examples

Example #1 : Set Order

include "easySQLite3.class.php";

$db = new easySQLite3("database.sqlite");

$db->setTable( "MyTable" );

$db->setOrder("timestamp", true);

var_dump( $db->showRecords() );

The above code will show data sorted by the column timestamp in a descending order.

Notes

Related Functions

  • getOrder - Get the order for querying/updating/deleting records of the database that was set using setOrder() function.
  • clearOrder - Clear the records order that was set using setOrder() function.
  • showRecords - Show records of a database using prepared statement.
  • updateRecords - Update records of a database using prepared statement.
  • deleteRecords - Delete records from a database using prepared statement.

Back to Functions list

Clone this wiki locally