Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 1 | ###################### |
| 2 | Database Utility Class |
| 3 | ###################### |
| 4 | |
Andrey Andreev | eaa60c7 | 2012-11-06 01:11:22 +0200 | [diff] [blame] | 5 | The Database Utility Class contains methods that help you manage your |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 6 | database. |
| 7 | |
James L Parry | 50d0649 | 2014-11-25 16:21:39 -0800 | [diff] [blame] | 8 | .. contents:: |
| 9 | :local: |
| 10 | :depth: 2 |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 11 | |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 12 | ****************************** |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 13 | Initializing the Utility Class |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 14 | ****************************** |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 15 | |
| 16 | .. important:: In order to initialize the Utility class, your database |
| 17 | driver must already be running, since the utilities class relies on it. |
| 18 | |
| 19 | Load the Utility Class as follows:: |
| 20 | |
| 21 | $this->load->dbutil() |
| 22 | |
Andrey Andreev | eaa60c7 | 2012-11-06 01:11:22 +0200 | [diff] [blame] | 23 | You can also pass another database object to the DB Utility loader, in case |
| 24 | the database you want to manage isn't the default one:: |
| 25 | |
| 26 | $this->myutil = $this->load->dbutil($this->other_db, TRUE); |
| 27 | |
| 28 | In the above example, we're passing a custom database object as the first |
| 29 | parameter and then tell it to return the dbutil object, instead of |
| 30 | assigning it directly to ``$this->dbutil``. |
| 31 | |
| 32 | .. note:: Both of the parameters can be used individually, just pass an empty |
| 33 | value as the first one if you wish to skip it. |
| 34 | |
| 35 | Once initialized you will access the methods using the ``$this->dbutil`` |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 36 | object:: |
| 37 | |
Andrey Andreev | eaa60c7 | 2012-11-06 01:11:22 +0200 | [diff] [blame] | 38 | $this->dbutil->some_method() |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 39 | |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 40 | **************************** |
| 41 | Using the Database Utilities |
| 42 | **************************** |
| 43 | |
| 44 | Retrieve list of database names |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 45 | ================================ |
| 46 | |
| 47 | Returns an array of database names:: |
| 48 | |
Joseph Wensley | f24f404 | 2011-10-06 22:53:29 -0400 | [diff] [blame] | 49 | $dbs = $this->dbutil->list_databases(); |
Andrew Podner | 79494dd | 2012-12-19 14:15:41 -0500 | [diff] [blame] | 50 | |
Joseph Wensley | f24f404 | 2011-10-06 22:53:29 -0400 | [diff] [blame] | 51 | foreach ($dbs as $db) |
| 52 | { |
| 53 | echo $db; |
| 54 | } |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 55 | |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 56 | |
| 57 | Determine If a Database Exists |
| 58 | ============================== |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 59 | |
| 60 | Sometimes it's helpful to know whether a particular database exists. |
| 61 | Returns a boolean TRUE/FALSE. Usage example:: |
| 62 | |
Joseph Wensley | f24f404 | 2011-10-06 22:53:29 -0400 | [diff] [blame] | 63 | if ($this->dbutil->database_exists('database_name')) |
| 64 | { |
| 65 | // some code... |
| 66 | } |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 67 | |
Andrey Andreev | eaa60c7 | 2012-11-06 01:11:22 +0200 | [diff] [blame] | 68 | .. note:: Replace *database_name* with the name of the table you are |
| 69 | looking for. This method is case sensitive. |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 70 | |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 71 | Optimize a Table |
| 72 | ================ |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 73 | |
| 74 | Permits you to optimize a table using the table name specified in the |
| 75 | first parameter. Returns TRUE/FALSE based on success or failure:: |
| 76 | |
Joseph Wensley | f24f404 | 2011-10-06 22:53:29 -0400 | [diff] [blame] | 77 | if ($this->dbutil->optimize_table('table_name')) |
| 78 | { |
| 79 | echo 'Success!'; |
| 80 | } |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 81 | |
Andrey Andreev | eaa60c7 | 2012-11-06 01:11:22 +0200 | [diff] [blame] | 82 | .. note:: Not all database platforms support table optimization. It is |
| 83 | mostly for use with MySQL. |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 84 | |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 85 | Repair a Table |
| 86 | ============== |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 87 | |
| 88 | Permits you to repair a table using the table name specified in the |
| 89 | first parameter. Returns TRUE/FALSE based on success or failure:: |
| 90 | |
Joseph Wensley | f24f404 | 2011-10-06 22:53:29 -0400 | [diff] [blame] | 91 | if ($this->dbutil->repair_table('table_name')) |
| 92 | { |
| 93 | echo 'Success!'; |
| 94 | } |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 95 | |
| 96 | .. note:: Not all database platforms support table repairs. |
| 97 | |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 98 | Optimize a Database |
| 99 | =================== |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 100 | |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 101 | Permits you to optimize the database your DB class is currently |
| 102 | connected to. Returns an array containing the DB status messages or |
| 103 | FALSE on failure. |
| 104 | |
| 105 | :: |
| 106 | |
Joseph Wensley | f24f404 | 2011-10-06 22:53:29 -0400 | [diff] [blame] | 107 | $result = $this->dbutil->optimize_database(); |
Andrew Podner | 79494dd | 2012-12-19 14:15:41 -0500 | [diff] [blame] | 108 | |
Joseph Wensley | f24f404 | 2011-10-06 22:53:29 -0400 | [diff] [blame] | 109 | if ($result !== FALSE) |
| 110 | { |
| 111 | print_r($result); |
| 112 | } |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 113 | |
Andrey Andreev | eaa60c7 | 2012-11-06 01:11:22 +0200 | [diff] [blame] | 114 | .. note:: Not all database platforms support table optimization. It |
| 115 | it is mostly for use with MySQL. |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 116 | |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 117 | Export a Query Result as a CSV File |
| 118 | =================================== |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 119 | |
| 120 | Permits you to generate a CSV file from a query result. The first |
Andrey Andreev | eaa60c7 | 2012-11-06 01:11:22 +0200 | [diff] [blame] | 121 | parameter of the method must contain the result object from your |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 122 | query. Example:: |
| 123 | |
Joseph Wensley | f24f404 | 2011-10-06 22:53:29 -0400 | [diff] [blame] | 124 | $this->load->dbutil(); |
Andrew Podner | 79494dd | 2012-12-19 14:15:41 -0500 | [diff] [blame] | 125 | |
Joseph Wensley | f24f404 | 2011-10-06 22:53:29 -0400 | [diff] [blame] | 126 | $query = $this->db->query("SELECT * FROM mytable"); |
Andrew Podner | 79494dd | 2012-12-19 14:15:41 -0500 | [diff] [blame] | 127 | |
Joseph Wensley | f24f404 | 2011-10-06 22:53:29 -0400 | [diff] [blame] | 128 | echo $this->dbutil->csv_from_result($query); |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 129 | |
| 130 | The second, third, and fourth parameters allow you to set the delimiter |
mrw | 7310e85 | 2012-03-26 11:25:26 -0300 | [diff] [blame] | 131 | newline, and enclosure characters respectively. By default commas are |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 132 | used as the delimiter, "\n" is used as a new line, and a double-quote |
| 133 | is used as the enclosure. Example:: |
| 134 | |
| 135 | $delimiter = ","; |
| 136 | $newline = "\r\n"; |
| 137 | $enclosure = '"'; |
| 138 | |
| 139 | echo $this->dbutil->csv_from_result($query, $delimiter, $newline, $enclosure); |
| 140 | |
Andrey Andreev | eaa60c7 | 2012-11-06 01:11:22 +0200 | [diff] [blame] | 141 | .. important:: This method will NOT write the CSV file for you. It |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 142 | simply creates the CSV layout. If you need to write the file |
| 143 | use the :doc:`File Helper <../helpers/file_helper>`. |
| 144 | |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 145 | Export a Query Result as an XML Document |
| 146 | ======================================== |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 147 | |
| 148 | Permits you to generate an XML file from a query result. The first |
| 149 | parameter expects a query result object, the second may contain an |
| 150 | optional array of config parameters. Example:: |
| 151 | |
Joseph Wensley | f24f404 | 2011-10-06 22:53:29 -0400 | [diff] [blame] | 152 | $this->load->dbutil(); |
Andrew Podner | 79494dd | 2012-12-19 14:15:41 -0500 | [diff] [blame] | 153 | |
Joseph Wensley | f24f404 | 2011-10-06 22:53:29 -0400 | [diff] [blame] | 154 | $query = $this->db->query("SELECT * FROM mytable"); |
Andrew Podner | 79494dd | 2012-12-19 14:15:41 -0500 | [diff] [blame] | 155 | |
Joseph Wensley | f24f404 | 2011-10-06 22:53:29 -0400 | [diff] [blame] | 156 | $config = array ( |
| 157 | 'root' => 'root', |
| 158 | 'element' => 'element', |
| 159 | 'newline' => "\n", |
Andrew Podner | 79494dd | 2012-12-19 14:15:41 -0500 | [diff] [blame] | 160 | 'tab' => "\t" |
Joseph Wensley | f24f404 | 2011-10-06 22:53:29 -0400 | [diff] [blame] | 161 | ); |
Andrew Podner | 79494dd | 2012-12-19 14:15:41 -0500 | [diff] [blame] | 162 | |
Joseph Wensley | f24f404 | 2011-10-06 22:53:29 -0400 | [diff] [blame] | 163 | echo $this->dbutil->xml_from_result($query, $config); |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 164 | |
Andrey Andreev | eaa60c7 | 2012-11-06 01:11:22 +0200 | [diff] [blame] | 165 | .. important:: This method will NOT write the XML file for you. It |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 166 | simply creates the XML layout. If you need to write the file |
| 167 | use the :doc:`File Helper <../helpers/file_helper>`. |
| 168 | |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 169 | ******************** |
| 170 | Backup Your Database |
| 171 | ******************** |
| 172 | |
| 173 | Database Backup Notes |
| 174 | ===================== |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 175 | |
| 176 | Permits you to backup your full database or individual tables. The |
| 177 | backup data can be compressed in either Zip or Gzip format. |
| 178 | |
Andrey Andreev | eaa60c7 | 2012-11-06 01:11:22 +0200 | [diff] [blame] | 179 | .. note:: This feature is only available for MySQL and Interbase/Firebird databases. |
Timothy Warren | ab189e1 | 2012-02-22 10:34:23 -0500 | [diff] [blame] | 180 | |
| 181 | .. note:: For Interbase/Firebird databases, the backup file name is the only parameter. |
Andrew Podner | 79494dd | 2012-12-19 14:15:41 -0500 | [diff] [blame] | 182 | |
Timothy Warren | ab189e1 | 2012-02-22 10:34:23 -0500 | [diff] [blame] | 183 | Eg. $this->dbutil->backup('db_backup_filename'); |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 184 | |
| 185 | .. note:: Due to the limited execution time and memory available to PHP, |
| 186 | backing up very large databases may not be possible. If your database is |
| 187 | very large you might need to backup directly from your SQL server via |
| 188 | the command line, or have your server admin do it for you if you do not |
| 189 | have root privileges. |
| 190 | |
| 191 | Usage Example |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 192 | ============= |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 193 | |
| 194 | :: |
| 195 | |
Joseph Wensley | f24f404 | 2011-10-06 22:53:29 -0400 | [diff] [blame] | 196 | // Load the DB utility class |
| 197 | $this->load->dbutil(); |
Andrew Podner | 79494dd | 2012-12-19 14:15:41 -0500 | [diff] [blame] | 198 | |
Joseph Wensley | f24f404 | 2011-10-06 22:53:29 -0400 | [diff] [blame] | 199 | // Backup your entire database and assign it to a variable |
| 200 | $backup =& $this->dbutil->backup(); |
Andrew Podner | 79494dd | 2012-12-19 14:15:41 -0500 | [diff] [blame] | 201 | |
Joseph Wensley | f24f404 | 2011-10-06 22:53:29 -0400 | [diff] [blame] | 202 | // Load the file helper and write the file to your server |
| 203 | $this->load->helper('file'); |
| 204 | write_file('/path/to/mybackup.gz', $backup); |
Andrew Podner | 79494dd | 2012-12-19 14:15:41 -0500 | [diff] [blame] | 205 | |
Joseph Wensley | f24f404 | 2011-10-06 22:53:29 -0400 | [diff] [blame] | 206 | // Load the download helper and send the file to your desktop |
| 207 | $this->load->helper('download'); |
| 208 | force_download('mybackup.gz', $backup); |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 209 | |
| 210 | Setting Backup Preferences |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 211 | ========================== |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 212 | |
| 213 | Backup preferences are set by submitting an array of values to the first |
Andrey Andreev | eaa60c7 | 2012-11-06 01:11:22 +0200 | [diff] [blame] | 214 | parameter of the ``backup()`` method. Example:: |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 215 | |
Joseph Wensley | f24f404 | 2011-10-06 22:53:29 -0400 | [diff] [blame] | 216 | $prefs = array( |
Andrey Andreev | eaa60c7 | 2012-11-06 01:11:22 +0200 | [diff] [blame] | 217 | 'tables' => array('table1', 'table2'), // Array of tables to backup. |
| 218 | 'ignore' => array(), // List of tables to omit from the backup |
| 219 | 'format' => 'txt', // gzip, zip, txt |
| 220 | 'filename' => 'mybackup.sql', // File name - NEEDED ONLY WITH ZIP FILES |
| 221 | 'add_drop' => TRUE, // Whether to add DROP TABLE statements to backup file |
| 222 | 'add_insert' => TRUE, // Whether to add INSERT data to backup file |
| 223 | 'newline' => "\n" // Newline character used in backup file |
Joseph Wensley | f24f404 | 2011-10-06 22:53:29 -0400 | [diff] [blame] | 224 | ); |
Andrew Podner | 79494dd | 2012-12-19 14:15:41 -0500 | [diff] [blame] | 225 | |
Joseph Wensley | f24f404 | 2011-10-06 22:53:29 -0400 | [diff] [blame] | 226 | $this->dbutil->backup($prefs); |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 227 | |
| 228 | Description of Backup Preferences |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 229 | ================================= |
Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 230 | |
Andrew Podner | 4851217 | 2012-12-20 07:56:19 -0500 | [diff] [blame] | 231 | ======================= ======================= ======================= ======================================================================== |
| 232 | Preference Default Value Options Description |
| 233 | ======================= ======================= ======================= ======================================================================== |
| 234 | **tables** empty array None An array of tables you want backed up. If left blank all tables will be |
| 235 | exported. |
| 236 | **ignore** empty array None An array of tables you want the backup routine to ignore. |
| 237 | **format** gzip gzip, zip, txt The file format of the export file. |
| 238 | **filename** the current date/time None The name of the backed-up file. The name is needed only if you are using |
| 239 | zip compression. |
| 240 | **add_drop** TRUE TRUE/FALSE Whether to include DROP TABLE statements in your SQL export file. |
| 241 | **add_insert** TRUE TRUE/FALSE Whether to include INSERT statements in your SQL export file. |
| 242 | **newline** "\\n" "\\n", "\\r", "\\r\\n" Type of newline to use in your SQL export file. |
| 243 | **foreign_key_checks** TRUE TRUE/FALSE Whether output should keep foreign key checks enabled. |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 244 | ======================= ======================= ======================= ======================================================================== |
| 245 | |
| 246 | *************** |
| 247 | Class Reference |
| 248 | *************** |
| 249 | |
Andrey Andreev | cd3d9db | 2015-02-02 13:41:01 +0200 | [diff] [blame] | 250 | .. php:class:: CI_DB_utility |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 251 | |
Andrey Andreev | cd3d9db | 2015-02-02 13:41:01 +0200 | [diff] [blame] | 252 | .. php:method:: backup([$params = array()]) |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 253 | |
Andrey Andreev | b906149 | 2014-12-04 16:33:24 +0200 | [diff] [blame] | 254 | :param array $params: An associative array of options |
Gabriel Potkány | 40bbd60 | 2015-02-04 14:06:47 +0100 | [diff] [blame] | 255 | :returns: raw/(g)zipped SQL query string |
Gabriel Potkány | cea5fb7 | 2015-02-04 08:22:06 +0100 | [diff] [blame] | 256 | :rtype: string |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 257 | |
Andrey Andreev | b906149 | 2014-12-04 16:33:24 +0200 | [diff] [blame] | 258 | Perform a database backup, per user preferences. |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 259 | |
Andrey Andreev | cd3d9db | 2015-02-02 13:41:01 +0200 | [diff] [blame] | 260 | .. php:method:: database_exists($database_name) |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 261 | |
Andrey Andreev | b906149 | 2014-12-04 16:33:24 +0200 | [diff] [blame] | 262 | :param string $database_name: Database name |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 263 | :returns: TRUE if the database exists, FALSE otherwise |
Andrey Andreev | b906149 | 2014-12-04 16:33:24 +0200 | [diff] [blame] | 264 | :rtype: bool |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 265 | |
Andrey Andreev | b906149 | 2014-12-04 16:33:24 +0200 | [diff] [blame] | 266 | Check for the existence of a database. |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 267 | |
Andrey Andreev | cd3d9db | 2015-02-02 13:41:01 +0200 | [diff] [blame] | 268 | .. php:method:: list_databases() |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 269 | |
| 270 | :returns: Array of database names found |
Andrey Andreev | b906149 | 2014-12-04 16:33:24 +0200 | [diff] [blame] | 271 | :rtype: array |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 272 | |
Andrey Andreev | b906149 | 2014-12-04 16:33:24 +0200 | [diff] [blame] | 273 | Retrieve a list of all the database names. |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 274 | |
Andrey Andreev | cd3d9db | 2015-02-02 13:41:01 +0200 | [diff] [blame] | 275 | .. php:method:: optimize_database() |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 276 | |
Andrey Andreev | b906149 | 2014-12-04 16:33:24 +0200 | [diff] [blame] | 277 | :returns: Array of optimization messages or FALSE on failure |
| 278 | :rtype: array |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 279 | |
Andrey Andreev | b906149 | 2014-12-04 16:33:24 +0200 | [diff] [blame] | 280 | Optimizes the database. |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 281 | |
Andrey Andreev | cd3d9db | 2015-02-02 13:41:01 +0200 | [diff] [blame] | 282 | .. php:method:: optimize_table($table_name) |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 283 | |
Andrey Andreev | b906149 | 2014-12-04 16:33:24 +0200 | [diff] [blame] | 284 | :param string $table_name: Name of the table to optimize |
| 285 | :returns: Array of optimization messages or FALSE on failure |
| 286 | :rtype: array |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 287 | |
Andrey Andreev | b906149 | 2014-12-04 16:33:24 +0200 | [diff] [blame] | 288 | Optimizes a database table. |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 289 | |
Andrey Andreev | cd3d9db | 2015-02-02 13:41:01 +0200 | [diff] [blame] | 290 | .. php:method:: repair_table($table_name) |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 291 | |
Andrey Andreev | b906149 | 2014-12-04 16:33:24 +0200 | [diff] [blame] | 292 | :param string $table_name: Name of the table to repair |
| 293 | :returns: Array of repair messages or FALSE on failure |
| 294 | :rtype: array |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 295 | |
Andrey Andreev | b906149 | 2014-12-04 16:33:24 +0200 | [diff] [blame] | 296 | Repairs a database table. |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 297 | |
Andrey Andreev | cd3d9db | 2015-02-02 13:41:01 +0200 | [diff] [blame] | 298 | .. php:method:: csv_from_results($query[, $delim = ','[, $newline = "\n"[, $enclosure = '"']]]) |
James L Parry | ee477c6 | 2014-11-25 16:15:18 -0800 | [diff] [blame] | 299 | |
Andrey Andreev | b906149 | 2014-12-04 16:33:24 +0200 | [diff] [blame] | 300 | :param object $query: A database result object |
| 301 | :param string $delim: The CSV field delimiter to use |
| 302 | :param string $newline: The newline character to use |
| 303 | :param string $enclosure: The enclosure delimiter to use |
| 304 | :returns: The generated CSV file as a string |
| 305 | :rtype: string |
| 306 | |
| 307 | Translates a database result object into a CSV document. |
| 308 | |
Andrey Andreev | cd3d9db | 2015-02-02 13:41:01 +0200 | [diff] [blame] | 309 | .. php:method:: xml_from_results($query[, $params = array()]) |
Andrey Andreev | b906149 | 2014-12-04 16:33:24 +0200 | [diff] [blame] | 310 | |
| 311 | :param object $query: A database result object |
| 312 | :param array $params: An associative array of preferences |
| 313 | :returns: The generated XML document as a string |
| 314 | :rtype: string |
| 315 | |
| 316 | Translates a database result object into an XML document. |