/** * Used to select 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 SelectQuery($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 database field names are fetched */ $field_names = $database->df_get_field_names($table_name); /** The field names are displayed */ echo "<h3>Field Names: </h3>"; print_R($field_names); /** The select fields */ $main_query = array(); /** Optional table name. Useful for multiple tables */ $main_query[0]['table'] = "pakphp_cached_data"; /** The select field for the above table */ $main_query[0]['field'] = "*"; /** 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 option table name of the above field. Useful for multiple tables */ $where_clause[0]['table'] = "pakphp_cached_data"; /** The operation. e.g =,<,>,!= */ $where_clause[0]['operation'] = "="; /** The operator. e.g AND, OR, NOT */ $where_clause[0]['operator'] = "AND"; /** The second field in where clause */ $where_clause[1]['field'] = "id"; /** The value of second field */ $where_clause[1]['value'] = "1"; /** The optional table name */ $where_clause[1]['table'] = "pakphp_cached_data"; /** The operation. e.g =,<,>,!= */ $where_clause[1]['operation'] = ">="; /** The operator. e.g AND, OR, NOT */ $where_clause[1]['operator'] = ""; /** The order by clause is set */ $database->df_set_order_by("pakphp_cached_data", "id", "DESC"); /** The group by clause is set */ $database->df_set_group_by("pakphp_cached_data", "created_on"); /** The limit clause is set */ $database->df_set_limits(0, 1); /** The database query is fetched */ $query = $database->df_build_query($main_query, $where_clause, 's'); echo "<h3>Database query: </h3>"; /** The query is displayed */ echo $query; /** All rows are fetched from database */ $all_rows = $database->df_all_rows($query); echo "<h3>All Table rows: </h3>"; print_r($all_rows); /** The first row is fetched from database */ $row = $database->df_first_row($query); echo "<h3>First Table row: </h3>"; print_r($row); /** 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(); }