# REFERENCE
// Class
new mysql\mop();
Argument: support 3 or 4 arguments.(counting from 0 position)
Argument type: All string.
Argument order: Database address, Database username, Database password, Database name, driver(optional) pdo or mysqli.
Documentation: Connection.
Usage:
//connect using default setting in mopconfig.php
$firstconnection = new mysql\mop($DB_ADDRESS,$DB_USER,$DB_PASS,$DB_NAME);
// OR connect to pdo
$firstconnection = new mysql\mop($DB_ADDRESS,$DB_USER,$DB_PASS,$DB_NAME,'pdo');
//OR connect to mysqli
$firstconnection = new mysql\mop($DB_ADDRESS,$DB_USER,$DB_PASS,$DB_NAME,'mysqli');
//method
->query();
Argument: support 1 argument.
Argument type: string.
Argument order: none.
Support: MYSQLI and PDO connection.
Documentation: Query.
Usage:
//query
$query = "SELECT ....";
$firstconnection->query($query);
// query with parameter
$query = "SELECT .... WHERE name = ? OR ?";
$firstconnection->query($query);
// Method
->param()
Argument: mysqli or pdo bind param argument.
Argument type: mysqli or pdo bind param type.
Argument order: mysqli or pdo bind param order.
Support: MYSQLI and PDO connection.
Documentation: Bind parameter.
Usage:
//if connection is by mysqli
$name = 'my name';
$name2 = 'second';
$firstconnection->param('ss',$name,$name2)
//if connection is by pdo (named parameter)
$name = 'my name';
$id = 5;
$firstconnection->param(:id,$id);
$firstconnection->param(:name,$name);
//if connection is by pdo (unnamed parameter)
$name = 'my name';
$id = 5;
$firstconnection->param(1,$id);
$firstconnection->param(2,$name);
// Method
->run()
Argument: none.
Argument type: none.
Argument order: none.
Support: MYSQLI and PDO connection.
Documentation: RUN.
Usage:
//use it after you've use query() or param() method
$firstconnection->run();
// Method
->run_all()
Argument: support 1 argument.
Argument type: array or object.
Argument order: parameter order.
Support: PDO connection only.
Documentation: Array binding, Object binding
Usage:
//Bind param and run directly without passing through param() method, also support associative array
// Check documentation for more
$arrayname = array('my name','second');
$firstconnection->run_all($arrayname);
// Also support object, check documentation for more.
$objectname = names() //object is reture
$firstconnection->run_all($objectname);
// Method
->add_query()
Argument: support 1 argument.
Argument type: string.
Argument order: QUERY.
Support: MYSQLI and PDO connection.
Documentation: Add query.
Usage:
//Add query to your previous query and get result immediately
$query = "SELECT....";
$firstconnection->add_query($query);
// Method
->get_column()
Argument: support 1 argument.
Argument type: string or integer.
Argument order: COLUMN INDEX.
Support: MYSQLI and PDO connection.
Documentation: Get column.
Usage:
//Get any column either by it's name or index
$name = 'name';
$index = 3;
$firstconnection->get_column($name); //array is return
$firstconnection->get_column($index); //array is return
// Method
->reconnect()
Argument: no argument.
Support: MYSQLI and PDO connection.
Documentation: Reconnect.
Connection will be close and reconnect.
// Method
->change_db()
Argument: support 1 argument.
Argument type: string.
Argument order: DATABASE NAME.
Support: MYSQLI and PDO connection.
Documentation: change database.
Usage:
$firstconnection->change_db('new database name');
// Method
->change_host()
Argument: support 1 argument.
Argument type: string.
Argument order: HOST NAME.
Support: MYSQLI and PDO connection.
Documentation: change host.
Usage:
$firstconnection->change_host('new host name');
// Method
->change_password()
Argument: support 1 argument.
Argument type: string.
Argument order: PASSWORD.
Support: MYSQLI and PDO connection.
Documentation: change password.
Usage:
$firstconnection->change_password('new password');
// Method
->change_username()
Argument: support 1 argument.
Argument type: string.
Argument order: USERNAME.
Support: MYSQLI and PDO connection.
Documentation: change username.
Usage:
$firstconnection->change_db('new username');
// Method
->change_all()
Argument: support 4 argument.
Argument type: string.
Argument order: HOST NAME, USERNAME, PASSWORD, DATABASE NAME.
Support: MYSQLI and PDO connection.
Documentation: change all information.
Usage:
$firstconnection->change_all('new host name', 'new username', 'new password', 'database name');
// Method
->multi_query()
Argument: support 1 argument.
Argument type: string.
Argument order: ALL QUERY.
Support: MYSQLI and PDO connection only.
Documentation: Multi query.
Usage:
//Run multiple query at once
$query = "SELECT...;SELECT...;INSERT...;UPDATE...";
$firstconnection->multi_query($query);
// Method
->multi_get_column()
Argument: support 2 argument.
Argument type: string or integer.
Argument order: QUERY INDEX, COLUMN INDEX.
Support: MYSQLI and PDO connection only.
Documentation: Multiple query Get column.
Usage:
//Get any column either by it's name or index in multi query
$name = 'name';
$index = 3;
$queryIndex = 1; // Query index in multi_query() method
$firstconnection->multi_get_column($queryIndex,$name);
$firstconnection->get_column($queryIndex,$index);
// Method
->multi_csv()
Argument: support 1 argument.
Argument type: integer.
Argument order: QUERY INDEX.
Support: MYSQLI and PDO connection only.
Documentation: multi csv.
Usage:
//Get any result as csv
$queryIndex = 0;
$firstconnection->multi_csv($queryIndex);
// Method
->multi_csv_header()
Argument: support 1 argument.
Argument type: integer.
Argument order: QUERY INDEX.
Support: MYSQLI and PDO connection only.
Documentation: multi csv with header.
Usage:
//Get any result as csv with header row
$queryIndex = 0;
$firstconnection->multi_csv_header($queryIndex);
// Method
->multi_header_row()
Argument: support 1 argument.
Argument type: integer.
Argument order: QUERY INDEX.
Support: MYSQLI and PDO connection only.
Documentation: multi header row.
Usage:
//Get any result as csv with header row
$query = "SELECT...;INSERT...;UPDATE...";
$firstconnection->multi_query($query);
$queryIndex = 0;
$firstconnection->multi_header_row($queryIndex);
// method
->multi_insert_id()
Argument: support 1 argument.
Argument type: integer.
Argument order: QUERY INDEX.
Support: MYSQLI and PDO connection only.
Documentation: Multi insert id.
Usage:
//get last insert id of any insert statement in multi query
$query = "SELECT...;INSERT...;UPDATE...";
$firstconnection->multi_query($query);
$firstconnection->multi_insert_id(1);
// method
->multi_num_of_rows()
Argument: support 1 argument.
Argument type: integer.
Argument order: QUERY INDEX.
Support: MYSQLI and PDO connection only.
Documentation: Multi num of rows.
Usage:
//get number of affected or selected rows
$query = "SELECT...;INSERT...;UPDATE...";
$firstconnection->multi_query($query);
$firstconnection->multi_num_of_rows(0);
// Method
->free_results()
Argument: no argument.
Support: MYSQLI and PDO connection.
Documentation: free results.
Usage:
$firstconnection->free_results();
// Method
->log_warning()
Argument: support 1 argument.
Argument type: boolean.
Argument order: none.
Support: MYSQLI connection only.
Documentation: log warning.
Usage:
//Change the state of log warning on the run
$firstconnection->log_warning(true);
// Method
->close()
Argument: none.
Argument type: none.
Argument order: none.
Support: MYSQLI and PDO connection.
Documentation: close connection.
Usage:
//Close the connection for either mysqli or pdo connection
$firstconnection->close();
// property
->csv
Type: string.
Support: MYSQLI and PDO connection.
Documentation: csv.
Usage:
//Get any result as csv, null if no result
$firstconnection->csv;
// method
->import_csv();
Argument: 5.
Support: MYSQLI and PDO connection.
Argument order: IS_STRING, CSV FILE OR STING, TABLE NAME, COLUMN ORDER (optional), HAS HEADER (optional).
Documentation: import csv.
Usage:
//import data using csv
$column_order = array('id', 'name')
$firstconnection->import_csv(false, 'path/to/csv/file', 'table_name', $column_order, false);
->import_csv_settings();
Argument: 3.
Support: MYSQLI and PDO connection.
Argument order: INSERT TYPE, SEPERATOR, ENCLOSURE.
Documentation: import csv settings.
Usage:
// set import csv settings
$firstconnection->import_csv_settings('update', ',', '"');
//property
->import_csv_num_of_rows;
Support: MYSQLI and PDO connection.
Documentation: import csv number of rows.
Usage:
// get number of affected row
$firstconnection->import_csv_num_of_rows;
// property
->multi_csv
Type: array.
Support: MYSQLI connection only.
As from version 2.1.0 ... It now support MYSQLI and PDO connection.
Documentation: Multi csv.
Usage:
//Get the header row of query index
$query = "SELECT...;INSERT...;UPDATE...";
$firstconnection->multi_query($query);
$firstconnection->multi_csv;
// property
->csv_header
Type: string.
Support: MYSQLI and PDO connection.
Documentation: csv header.
Usage:
//Get any result as csv with header, null if no result
$firstconnection->csv_header;
// property
->multi_csv_header
Type: array.
Support: MYSQLI connection only.
As from version 2.1.0 ... It now support MYSQLI and PDO connection.
Documentation: Multi csv header.
Usage:
//Get the header row of query index
$query = "SELECT...;INSERT...;UPDATE...";
$firstconnection->multi_query($query);
$firstconnection->multi_csv_header;
// property
->header_row
Type: array.
Support: MYSQL and PDO connection.
Documentation: header row.
Usage:
//Get any header row result, null if no result
$firstconnection->header_row;
// property
->multi_header_row
Type: array.
Support: MYSQLI connection only.
As from version 2.1.0 ... It now support MYSQLI and PDO connection.
Documentation: Multi header row.
Usage:
//Get the header row of query index
$query = "SELECT...;INSERT...;UPDATE...";
$firstconnection->multi_query($query);
$firstconnection->multi_header_row;
// property
->error
Type: boolean.
Support: MYSQLI and PDO connection.
Documentation: error.
Usage:
//check if there is any error
$firstconnection->error;
// property
->error_message
Type: string.
Support: MYSQLI and PDO connection.
Documentation: error message.
Usage:
//It return an error message if there is any
$firstconnection->error_message;
// property
->warning
Type: boolean.
Support: MYSQLI connection only and is NOT supported by multi query.
Documentation: warning.
Usage:
//check if there is any warning
$firstconnection->warning;
// property
->num_of_warnings
Type: Integer.
Support: MYSQLI connection only and NOT supported by multi query.
Documentation: warning error number.
Usage:
//Get number of warnings that occur
$firstconnection->num_of_warnings;
// property
->warning_errno
Type: array.
Support: MYSQLI connection only and NOT supported by multi query.
Documentation: warning error number.
Usage:
//Get warning error number if there is any
//loop through to get all number
$firstconnection->warning_errno;
// property
->warning_message
Type: array.
Support: MYSQLI connection only and NOT supported by multi query.
Documentation: warning message.
Usage:
//Get warning message of any query that has warning
//loop through to get all message
$firstconnection->warning_message;
// property
->warning_sqlstate
Type: array.
Support: MYSQLI connection only and NOT supported by multi query.
Documentation: warning sqlstate.
Usage:
//Get warning sql state of any query that has warning
//loop through to get all state
$firstconnection->warning_sqlstate;
// property
->num_of_rows
Type: Integer.
Support: MYSQLI and PDO connection.
Documentation: Number of rows.
Usage:
//Get number of affected of selected rows
$firstconnection->num_of_rows;
// property
->insert_id
Type: Integer.
Support: MYSQLI and PDO connection.
Documentation: Last Insert id.
Usage:
//check if there is any warning
$firstconnection->insert_id;
// property
->connect
Type: object.
Support: MYSQLI and PDO connection.
Documentation: connect.
Usage:
//Run your query your way using the connect property
$newconnect->connect;
Documentation: procedure in multi query.