PHP Class App\services\Database

Show file Open project: printempw/blessing-skin-server Class Usage Examples

Public Methods

Method Description
__construct ( array $config = null ) Construct with a config array.
__destruct ( )
delete ( $condition = null, $table = null )
fetchArray ( $sql )
getNumRows ( $key, $value, $table = null )
getRecordNum ( $table = null )
has ( $key, $value, $table = null )
hasTable ( $tableName )
insert ( $data, $table = null )
prepareConnection ( array $config = null ) : mysqli Try to connect to the database with given config.
query ( $sql )
select ( string $key, string $value, array $condition = null, string $table = null, boolean $dont_fetch_array = false ) : array | resources Select records from table
table ( $tableName, $no_prefix = false )
update ( $key, $value, $condition = null, $table = null )

Private Methods

Method Description
where ( array $condition ) : string Generate where statement

Method Details

__construct() public method

Construct with a config array.
public __construct ( array $config = null )
$config array

__destruct() public method

public __destruct ( )

delete() public method

public delete ( $condition = null, $table = null )

fetchArray() public method

public fetchArray ( $sql )

getNumRows() public method

public getNumRows ( $key, $value, $table = null )

getRecordNum() public method

public getRecordNum ( $table = null )

has() public method

public has ( $key, $value, $table = null )

hasTable() public method

public hasTable ( $tableName )

insert() public method

public insert ( $data, $table = null )

prepareConnection() public static method

Try to connect to the database with given config.
public static prepareConnection ( array $config = null ) : mysqli
$config array
return mysqli

query() public method

public query ( $sql )

select() public method

Select records from table
public select ( string $key, string $value, array $condition = null, string $table = null, boolean $dont_fetch_array = false ) : array | resources
$key string
$value string
$condition array See function `where`
$table string Which table to operate
$dont_fetch_array boolean Return resources if true
return array | resources

table() public method

public table ( $tableName, $no_prefix = false )

update() public method

public update ( $key, $value, $condition = null, $table = null )