\it\thecsea\mysqltcsMysqltcs

Class Mysqltcs Main class, this class create the mysql connection, and allow you to make query.

If you want to perform efficiently common tasks like a simple insert you can instance MysqlOperations passing the connection instantiated before

Summary

Methods
Properties
Constants
__construct()
__destruct()
__clone()
__toString()
setLogger()
getLogger()
setSimpleLogger()
getInstanceNumber()
isConnected()
getConnectionThreadId()
getLastId()
getAffectedRows()
getEscapedString()
executeQuery()
setAutocommit()
commit()
rollBack()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
log()
getConnection()
$instanceNumber
$instances
$host
$user
$password
$name
$newConnection
$key
$cert
$ca
$mysqlRef
$mysqliRef
$mysqlConnections
$logger
N/A

Properties

$instanceNumber

$instanceNumber : integer

Type

integer

$instances

$instances : integer

Type

integer

$host

$host : String

Type

String

$user

$user : String

Type

String

$password

$password : String

Type

String

$name

$name : String

Type

String

$newConnection

$newConnection : boolean

Type

boolean

$key

$key : string

Type

string

$cert

$cert : string

Type

string

$ca

$ca : string

Type

string

$mysqliRef

$mysqliRef : \mysqli

Type

\mysqli

Methods

__construct()

__construct(String  $host, String  $user, String  $password, String  $name, boolean  $newConnection = true, string  $key = "", string  $cert = "", string  $ca = "") 

Get a connection to mysql

Parameters

String $host
String $user
String $password
String $name

database name

boolean $newConnection

optional, default true. If it is false the class uses an already open connection if it possible

string $key

optional

string $cert

optional

string $ca

optional

Throws

\it\thecsea\mysqltcs\connections\MysqlConnectionException

__destruct()

__destruct() 

__clone()

__clone() 

create a new mysql connection ref

Throws

\it\thecsea\mysqltcs\connections\MysqlConnectionException

__toString()

__toString() : string

Returns

string

setLogger()

setLogger(\it\thecsea\mysqltcs\mysqltcsLogger|\it\thecsea\mysqltcs\SimpleLogger  $logger) 

Set the logger, set null if you don't want to log

Parameters

\it\thecsea\mysqltcs\mysqltcsLogger|\it\thecsea\mysqltcs\SimpleLogger $logger

getLogger()

getLogger() : \it\thecsea\mysqltcs\mysqltcsLogger|\it\thecsea\mysqltcs\SimpleLogger

Return the logger, it is not a clone so you can alter it

Returns

\it\thecsea\mysqltcs\mysqltcsLogger|\it\thecsea\mysqltcs\SimpleLogger

setSimpleLogger()

setSimpleLogger() 

set the simple logger as logger

getInstanceNumber()

getInstanceNumber() : integer

Returns

integer

isConnected()

isConnected() : boolean

Get if mysqltcs is connected (using mysqli::ping)

Returns

boolean —

if true mysqltcs is connected

getConnectionThreadId()

getConnectionThreadId() : integer

Get the thread id (it can be used as mysqli identifier)

Returns

integer

getLastId()

getLastId() : mixed

get the id of the last element inserted

Returns

mixed

getAffectedRows()

getAffectedRows() : integer

get affected rows number

Returns

integer

getEscapedString()

getEscapedString(  $string) : string

return the escaped string

Parameters

$string

Returns

string

executeQuery()

executeQuery(String  $query) : boolean|\mysqli_result

Execute an sql query and log it

Parameters

String $query

sql query

Throws

\it\thecsea\mysqltcs\MysqltcsException

thrown if an sql error is occurred, the message contain the mysql error and query

Returns

boolean|\mysqli_result —

mysql query return

setAutocommit()

setAutocommit(boolean  $autocommit) 

Set autocommit

Parameters

boolean $autocommit

Throws

\it\thecsea\mysqltcs\MysqltcsException

on error

commit()

commit() 

Commit the transaction

Throws

\it\thecsea\mysqltcs\MysqltcsException

on commit error

rollBack()

rollBack() 

Rollback (abort) the transaction

Throws

\it\thecsea\mysqltcs\MysqltcsException

on rollback error

log()

log(String  $mex) 

Parameters

String $mex

getConnection()

getConnection() 

Get the connection according to newConnection value

Throws

\it\thecsea\mysqltcs\connections\MysqlConnectionException