PHP Class Microweber\Providers\DatabaseManager

Inheritance: extends Microweber\Providers\Database\Utils, use trait Microweber\Traits\QueryFilter, use trait Microweber\Traits\ExtendedSave
显示文件 Open project: microweber/microweber

Public Properties

Property Type Description
$app Microweber\Application
$use_cache

Public Methods

Method Description
__construct ( $app = null ) trait to save extended data, such as attributes, categories and images
delete_by_id ( string $table, integer | string $id, string $field_name = 'id' ) : boolean Deletes item by id from db table.
get ( $table, string | array $params = null ) : mixed Get items from the database.
get_by_id ( string $table, integer | string $id, string $field_name = 'id' ) : array | boolean | mixed Get table row by id.
last_id ( $table ) : boolean | integer Get last id from a table.
q ( $q, $silent = false )
query ( string $q, string | boolean $cache_id = false, string | boolean $cache_group = 'global', boolean $only_query = false, array | boolean $connection_settings = false ) : array | boolean | mixed Executes plain query in the database.
save ( $table, $data = false, boolean $data_to_save_options = false ) : string | integer Generic save data function, it saves data to the database.
table ( $table )

Method Details

__construct() public method

trait to save extended data, such as attributes, categories and images
public __construct ( $app = null )

delete_by_id() public method

Deletes item by id from db table.
public delete_by_id ( string $table, integer | string $id, string $field_name = 'id' ) : boolean
$table string Your da table name
$id integer | string The id to delete
$field_name string You can set custom column to delete by it, default is id
return boolean

get() public method

You can use this handy function to get whatever you need from any db table.
public get ( $table, string | array $params = null ) : mixed
$params string | array parameters for the DB
return mixed Array with data or false or integer if page_count is set

get_by_id() public method

It returns full db row from a db table
public get_by_id ( string $table, integer | string $id, string $field_name = 'id' ) : array | boolean | mixed
$table string Your table
$id integer | string The id to get
$field_name string You can set custom column to get by it, default is id
return array | boolean | mixed

last_id() public method

Get last id from a table.
public last_id ( $table ) : boolean | integer
$table
return boolean | integer

q() public method

public q ( $q, $silent = false )

query() public method

You can use this function to make queries in the db by writing your own sql The results are returned as array or false if nothing is found
public query ( string $q, string | boolean $cache_id = false, string | boolean $cache_group = 'global', boolean $only_query = false, array | boolean $connection_settings = false ) : array | boolean | mixed
$q string Your SQL query
$cache_id string | boolean It will save the query result in the cache. Set to false to disable
$cache_group string | boolean Stores the result in certain cache group. Set to false to disable
$only_query boolean If set to true, will perform only a query without returning a result
$connection_settings array | boolean
return array | boolean | mixed

save() public method

Generic save data function, it saves data to the database.
public save ( $table, $data = false, boolean $data_to_save_options = false ) : string | integer
$table
$data
$data_to_save_options boolean
return string | integer The id of the saved row.

table() public method

public table ( $table )

Property Details

$app public_oe property

public Application,Microweber $app
return Microweber\Application

$use_cache public_oe property

public $use_cache