\it\thecsea\mysqltcsMysqltcsOperations

Class MysqltcsOperations This class allow you to perform efficiently common tasks like a simple insert you have to instance this passing a Mysqltcs connection instantiated before

Summary

Methods
Properties
Constants
__construct()
__toString()
__clone()
getMysqltcs()
setMysqltcs()
getDefaultFrom()
setDefaultFrom()
isDefaultQuotes()
setDefaultQuotes()
getLastId()
showTables()
showDatabases()
getTableInfo()
insert()
getValue()
getList()
getListAdvanced()
deleteRows()
update()
getEscapedString()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
mysqltcsCheck()
getSimpleList()
insertValues()
fromCheck()
updateSet()
$mysqltcs
$from
$quotes
N/A

Properties

$from

$from : String

Type

String

$quotes

$quotes : boolean

Type

boolean

Methods

__construct()

__construct(\it\thecsea\mysqltcs\Mysqltcs  $mysqltcs, string  $defaultFrom = "", boolean|true  $defaultQuotes = true) 

Instance the class based on the mysqltcs connections and $defaultFrom and $defaultQuotes value that are used as default values in all method, but you can set local value for every method

Parameters

\it\thecsea\mysqltcs\Mysqltcs $mysqltcs

mysqltcs connected to a valid databases

string $defaultFrom

value of from mysql from label. It can assume all data types, for example it can be simply a table or a more complex type like a subquery, if you want use complex data set quotes to false. Obviously you can use complex constructs like JOIN

boolean|true $defaultQuotes

if true ` are inserted at the start and at the end of $from. it suggested to keep this true if you use only one table in from label

Throws

\it\thecsea\mysqltcs\MysqltcsException

__toString()

__toString() : string

Returns

string

__clone()

__clone() 

This entails that you can clone every instance of this class

setMysqltcs()

setMysqltcs(\it\thecsea\mysqltcs\Mysqltcs  $mysqltcs) 

Parameters

\it\thecsea\mysqltcs\Mysqltcs $mysqltcs

Throws

\it\thecsea\mysqltcs\MysqltcsException

getDefaultFrom()

getDefaultFrom() : String

Returns

String

setDefaultFrom()

setDefaultFrom(String  $from) 

Parameters

String $from

isDefaultQuotes()

isDefaultQuotes() : boolean

Returns

boolean

setDefaultQuotes()

setDefaultQuotes(boolean  $quotes) 

Parameters

boolean $quotes

getLastId()

getLastId() : mixed

get the id of the last element inserted

Returns

mixed

showTables()

showTables() : array

return all tables names of the current db

Throws

\it\thecsea\mysqltcs\MysqltcsException

thrown on mysql error, for example invalid data or permission denied

Returns

array

showDatabases()

showDatabases() : array

return all databases names of the current server

Throws

\it\thecsea\mysqltcs\MysqltcsException

thrown on mysql error, for example invalid data or permission denied

Returns

array

getTableInfo()

getTableInfo(  $returnName, string  $from = "") : string|null

Return $returnName value info of table indicated in $from

Parameters

$returnName
string $from

you have to set to a table. If you leave this empty default value is used

Throws

\it\thecsea\mysqltcs\MysqltcsException

thrown on mysql error, for example invalid data or permission denied

Returns

string|null

insert()

insert(string  $fields, array|string  $values, string  $from = "") 

Insert a row or multiple rows

Parameters

string $fields

SQL list of flieds, you can even use subquery or "as" (SQL). The simplest example is: `field1`, `field2`, ...

array|string $values

you can use this parameter in two different way:

  • you can pass a string array of rows
  • you can pass a string of a single row

in any case the string(each element of array) must be composed by an SQL string well formatted, for example: \'data1\', \'data2\'
N.B. if you want pass an array you have to pass an array like this: array("\'data11\', \'data12\'", \'data21\', \'data22\')
CAUTION: you have to insert \' delimiters for varchar or text field, but not for numerical fields.

string $from

you can use this field to specify the INTO value, if you leave this empty, default value is used ($defaultFrom)

Throws

\it\thecsea\mysqltcs\MysqltcsException

thrown on mysql error, for example invalid data or permission denied

getValue()

getValue(string  $field, string  $where, string  $from = "", boolean|null  $quotes = null) : string|null

Get the first value of $field based on $where.<br> This method does not make any type of order, so you are not able to know which value is taken if there are more values under $where condition, so we suggest to use this method only with conditions that generates only one value. If you have more values under condition we suggest to use getList method

Parameters

string $field

filed name

string $where

the where condition to get the value,obviously you can use different tables (via chain form: e.g. tableName.id)

string $from

you can use this field to specify the from value, if you leave this empty, default value is used. Obviously you can use complex constructs like JOIN

boolean|null $quotes

you can use this field to specify if insert ` at limits of $from or not. If you leave this empty,default value is used

Throws

\it\thecsea\mysqltcs\MysqltcsException

thrown on mysql error, for example invalid data or permission denied

Returns

string|null —

the value

getList()

getList(string  $select, string  $where, string  $order = "", string  $from = "", boolean|null  $quotes = null) : array

This method make a select and return the results as a associative matrix, you can make a simple select in one or in more tables, you can make a select with order or not. This is a less powerful method than getListAdvanced

Parameters

string $select

the select SQL field. Obviously you can use different tables (via chain form: e.g. tableName.id),you can also use SQL construct like 'as'

string $where

the where condition to get the values,obviously you can use different tables (via chain form: e.g. tableName.id)

string $order

you can insert the order SQL rules, if you leave this empty the query is executed without any order. Order example: 'id ASC'

string $from

you can use this field to specify the from value, if you leave this empty, default value is used. Obviously you can use complex constructs like JOIN

boolean|null $quotes

you can use this field to specify if insert ` at limits of $from or not. If you leave this empty,default value is used

Throws

\it\thecsea\mysqltcs\MysqltcsException

thrown on mysql error, for example invalid data or permission denied

Returns

array —

the associative matrix of results

getListAdvanced()

getListAdvanced(string  $select, string  $where, string  $other = "", string  $from = "", boolean|null  $quotes = null) : array

This method make a select and return the results as a associative matrix. This is method is more powerful than getList, in fact it allows to specify all advanced SQL constructs, not only order, but even for example group by and having

Parameters

string $select

the select SQL field. Obviously you can use different tables (via chain form: e.g. tableName.id), you can also use SQL construct like 'as'

string $where

the where condition to get the values,obviously you can use different tables (via chain form: e.g. tableName.id)

string $other

you can insert what you want (obviously it must be SQL)

string $from

you can use this field to specify the from value, if you leave this empty, default value is used. Obviously you can use complex constructs like JOIN

boolean|null $quotes

you can use this field to specify if insert ` at limits of $from or not. If you leave this empty,default value is used

Throws

\it\thecsea\mysqltcs\MysqltcsException

thrown on mysql error, for example invalid data or permission denied

Returns

array —

the associative matrix of results

deleteRows()

deleteRows(string  $where, string  $from = "", boolean|null  $quotes = null) : integer

Delete one or more rows according to $where condition

Parameters

string $where

the where condition to delete values,obviously you can use different tables (via chain form: e.g. tableName.id)

string $from

you can use this field to specify the from value, if you leave this empty, default value is used. Obviously you can use complex constructs like JOIN

boolean|null $quotes

you can use this field to specify if insert ` at limits of $from or not. If you leave this empty,default value is used

Throws

\it\thecsea\mysqltcs\MysqltcsException

thrown on mysql error, for example invalid data or permission denied

Returns

integer —

the deleted rows number

update()

update(array  $values, string  $where, string  $from = "", boolean|null  $quotes = null) : integer

make an SQL update

Parameters

array $values

associative matrix of new values, the key must be the field name. For example: array("id"=>"5", "value"="'test3'").
CAUTION: you have to insert \' delimiters for varchar or text field, but not for numerical fields
Obviously you can use different tables (via chain form: e.g. tableName.id)

string $where

the where condition to update values, obviously you can use different tables (via chain form: e.g. tableName.id)

string $from

you can use this field to specify the from value, if you leave this empty, default value is used. Obviously you can use complex constructs like JOIN

boolean|null $quotes

you can use this field to specify if insert ` at limits of $from or not. If you leave this empty,default value is used

Throws

\it\thecsea\mysqltcs\MysqltcsException

thrown on mysql error, for example invalid data or permission denied

Returns

integer —

the updated rows number

getEscapedString()

getEscapedString(  $string) : string

return the escaped string

Parameters

$string

Returns

string

mysqltcsCheck()

mysqltcsCheck(\it\thecsea\mysqltcs\Mysqltcs  $mysqltcs) 

throw exception if mysqltcs passed is not valid

Parameters

\it\thecsea\mysqltcs\Mysqltcs $mysqltcs

Throws

\it\thecsea\mysqltcs\MysqltcsException

getSimpleList()

getSimpleList(String  $query, integer  $pos) : array

return an array of values of each row of element in the $pos column

Parameters

String $query
integer $pos

column number

Throws

\it\thecsea\mysqltcs\MysqltcsException

thrown on mysql error, for example invalid data or permission denied

Returns

array

insertValues()

insertValues(array|string  $array, boolean|false  $newline = false) : string

Return the formatted string for a multiple insert

Parameters

array|string $array

it can be a string array of multiple insert or a string of a single insert, In any case the String must be the SQL single insert string

boolean|false $newline

if true each insert is separated by \n

Returns

string —

formatted string

fromCheck()

fromCheck(string  $from, boolean|null  $quotes = null) : string

Check $from, it returns the correct from (default or passed with/without quotes)

Parameters

string $from
boolean|null $quotes

Returns

string —

new from

updateSet()

updateSet(array  $values) : string

return the SQL string for set

Parameters

array $values

associative array,the key must be the SQL field name

Returns

string —

set