DB
in package
Connection class use for CRUD opration and work with MySQL database
Table of Contents
- $db : mixed
- Keep query and data for functions
- __construct() : mixed
- Create a database connection object for CRUD operatian
- __destruct() : mixed
- Close database work
- connectToDatabase() : bool
- Connect to database
- createDatabase() : bool
- Create new data base
- delete() : bool
- Delete a value from your db
- dropDatabase() : bool
- Drop a database
- find() : mixed
- Find a single data in database
- insert() : bool
- insert data to table
- query() : mixed
- select() : mixed
- Select data from database
- update() : bool
- Update values in database
- connectionFailed() : void
- echo connection error and die
Properties
$db
Keep query and data for functions
private
mixed
$db
Methods
__construct()
Create a database connection object for CRUD operatian
public
__construct(string $server_name, string $user_name, string $password[, string $database_name = "" ]) : mixed
Parameters
- $server_name : string
-
Server name
- $user_name : string
-
User name
- $password : string
-
User pass
- $database_name : string = ""
-
Database name, default is 'null' and only connect to server
Tags
Return values
mixed —__destruct()
Close database work
public
__destruct() : mixed
Return values
mixed —connectToDatabase()
Connect to database
public
connectToDatabase(string $server_name, string $user_name, string $password[, string $database_name = "" ]) : bool
Parameters
- $server_name : string
-
Server Name
- $user_name : string
-
User name
- $password : string
-
User pass
- $database_name : string = ""
-
Database name, defaul is 'null' and only connect to server
Tags
Return values
bool —createDatabase()
Create new data base
public
createDatabase(string $database_name) : bool
Parameters
- $database_name : string
-
Name of new database
Tags
Return values
bool —delete()
Delete a value from your db
public
delete(string $table, string $where) : bool
Parameters
- $table : string
-
Table name
- $where : string
-
which data you need to delete, default is '1=1'
Tags
Return values
bool —dropDatabase()
Drop a database
public
dropDatabase(string $database_name[, string $confirm = "no" ]) : bool
Parameters
- $database_name : string
-
Name of database
- $confirm : string = "no"
-
For confirm proccess fill secound param with 'yes' default is 'no'
Tags
Return values
bool —find()
Find a single data in database
public
find(string $column, string $table[, string $where = "1=1" ]) : mixed
Parameters
- $column : string
-
Column name
- $table : string
-
Table name
- $where : string = "1=1"
-
Contition, default is '1=1'
Tags
Return values
mixed —false|string
insert()
insert data to table
public
insert(string $table, array<string|int, mixed> $columns, array<string|int, mixed> $values) : bool
Parameters
- $table : string
-
Table name
- $columns : array<string|int, mixed>
-
Columns Name
- $values : array<string|int, mixed>
-
Values
Tags
Return values
bool —query()
public
query(string $SQL) : mixed
Parameters
- $SQL : string
Return values
mixed —select()
Select data from database
public
select(array<string|int, mixed> $columns, string $table[, string $where = "1=1" ]) : mixed
Parameters
- $columns : array<string|int, mixed>
-
Columns name
- $table : string
-
Table name
- $where : string = "1=1"
-
Where?, default is '1=1'
Tags
Return values
mixed —false|array
update()
Update values in database
public
update(string $table, array<string|int, mixed> $set[, string $where = "1=1" ]) : bool
Parameters
- $table : string
-
Table name
- $set : array<string|int, mixed>
-
which columns must be update
- $where : string = "1=1"
-
add a where condition, default is '1=1'
Tags
Return values
bool —connectionFailed()
echo connection error and die
private
connectionFailed() : void