$mysqltcs
$mysqltcs : \it\thecsea\mysqltcs\Mysqltcs
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
$mysqltcs : \it\thecsea\mysqltcs\Mysqltcs
__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
\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 |
getMysqltcs() : \it\thecsea\mysqltcs\Mysqltcs
setMysqltcs(\it\thecsea\mysqltcs\Mysqltcs $mysqltcs)
\it\thecsea\mysqltcs\Mysqltcs | $mysqltcs |
getTableInfo( $returnName, string $from = "") : string|null
Return $returnName value info of table indicated in $from
$returnName | ||
string | $from | you have to set to a table. If you leave this empty default value is used |
thrown on mysql error, for example invalid data or permission denied
insert(string $fields, array|string $values, string $from = "")
Insert a row or multiple rows
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:
in any case the string(each element of array) must be composed by an SQL string well formatted, for example:
\'data1\', \'data2\' |
string | $from | you can use this field to specify the INTO value, if you leave this empty, default value is used ($defaultFrom) |
thrown on mysql error, for example invalid data or permission denied
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
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 |
thrown on mysql error, for example invalid data or permission denied
the value
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
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 |
thrown on mysql error, for example invalid data or permission denied
the associative matrix of results
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
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 |
thrown on mysql error, for example invalid data or permission denied
the associative matrix of results
deleteRows(string $where, string $from = "", boolean|null $quotes = null) : integer
Delete one or more rows according to $where condition
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 |
thrown on mysql error, for example invalid data or permission denied
the deleted rows number
update(array $values, string $where, string $from = "", boolean|null $quotes = null) : integer
make an SQL update
array | $values | associative matrix of new values, the key must be the field name.
For example: array("id"=>"5", "value"="'test3'"). |
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 |
thrown on mysql error, for example invalid data or permission denied
the updated rows number
mysqltcsCheck(\it\thecsea\mysqltcs\Mysqltcs $mysqltcs)
throw exception if mysqltcs passed is not valid
\it\thecsea\mysqltcs\Mysqltcs | $mysqltcs |
getSimpleList(String $query, integer $pos) : array
return an array of values of each row of element in the $pos column
String | $query | |
integer | $pos | column number |
thrown on mysql error, for example invalid data or permission denied
insertValues(array|string $array, boolean|false $newline = false) : string
Return the formatted string for a multiple insert
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 |
formatted string