ImDb
Kind: global class
Summary: A utility class which provides an easy access to the databases defined by the WSX5 user.
To use it, you must include x5engine.php in your code.
- ImDb
- new ImDb($host, $user, $pwd, $db)
- .testConnection() ⇒
Boolean
- .closeConnection() ⇒
Void
- .createTable($name, $fields) ⇒
Boolean
- .deleteTable($table) ⇒
Void
- .tableExists($table) ⇒
Boolean
- .error() ⇒
Array
- .lastInsertId() ⇒
Number
- .query($query) ⇒
Array
- .escapeString($string) ⇒
String
- .affectedRows() ⇒
Number
new ImDb($host, $user, $pwd, $db)
Create a new ImDb Object
Param | Type | Description |
---|---|---|
$host | String |
The database host address |
$user | String |
The database username |
$pwd | String |
The database password |
$db | String |
The database name |
.testConnection() ⇒ Boolean
Check if the class is connected or not to a db
Kind: instance method of ImDb
Returns: Boolean
- True if the class is connected to a DB. False otherwise.
.closeConnection() ⇒ Void
Close the connection
Kind: instance method of ImDb
.createTable($name, $fields) ⇒ Boolean
Create a new table or update an existing one.
Kind: instance method of ImDb
Returns: Boolean
- True if the table was created succesfully.
Param | Type | Description |
---|---|---|
$name | String |
The table name |
$fields | Array |
The table fields list as array of associative arrays (one array item foreach table field). must be passed as stated in the example. |
Example
$db->createTable('tableName', array(
"field1" => array(
"type" => "INTEGER",
"null" => false,
"auto_increment" => true,
"primary" => true
),
"field2" => array(
"type" => "TEXT",
"null" => true,
"auto_increment" => false,
"more" => "CHARACTER SET UTF-8"
))
);
.deleteTable($table) ⇒ Void
Delete a table from the database.
Kind: instance method of ImDb
Param | Type | Description |
---|---|---|
$table | String |
The table name |
.tableExists($table) ⇒ Boolean
Check if the table exists
Kind: instance method of ImDb
Returns: Boolean
- True if the table exists. False otherwise.
Param | Type | Description |
---|---|---|
$table | String |
The table name |
.error() ⇒ Array
Get the last MySQL error.
Kind: instance method of ImDb
.lastInsertId() ⇒ Number
Provide the last inserted ID of the AUTOINCREMENT column
Kind: instance method of ImDb
Returns: Number
- The id of the latest insert operation
.query($query) ⇒ Array
Execute a MySQL query.
Kind: instance method of ImDb
Returns: Array
- The query result or FALSE on error
Param | Type |
---|---|
$query | String |
.escapeString($string) ⇒ String
Escape a MySQL query string.
Kind: instance method of ImDb
Returns: String
- The escaped string
Param | Type | Description |
---|---|---|
$string | String |
The string to escape |
.affectedRows() ⇒ Number
Return the number of affected rows in the last query.
Kind: instance method of ImDb
Returns: Number
- The number of affected rows.