Procedural File: _upgrade.funcs.php
Source Location: /blogs/inc/_misc/_upgrade.funcs.php
This file implements functions useful for upgrading DB schema.
This file is part of the b2evolution/evocms project - http://b2evolution.net/. See also http://sourceforge.net/projects/evocms/.
| Author: | fplanque: Francois PLANQUE |
| Author: | Wordpress team |
| Author: | blueyed: Daniel HAHLER |
| Version: | $Id: _upgrade.funcs.php,v 1.22.2.3 2007/01/14 22:00:27 blueyed Exp $ |
| Copyright: | (c)2003-2006 by Francois PLANQUE - http://fplanque.net/. Parts of this file are copyright (c)2004-2005 by Daniel HAHLER - https://thequod.de/. db_delta() is based on dbDelta() from Wordpress, see http://trac.wordpress.org/file/trunk/wp-admin/upgrade-functions.php. |
| Filesource: | Source Code for this file |
| License: | GNU General Public License (GPL) |
|
Get the delta query to adjust the current database according to a given (list of) "CREATE TABLE"-, "CREATE DATABASE"-, "INSERT"- or "UPDATE"-statement(s).
It's not recommend to use INSERT or UPDATE statements with this function, as they are just handled "as-is".
NOTE:
- You should use single quotes (') to give string type values (this is in fact required for ENUM and SET fields).
- KEYs for AUTO_INCREMENT fields should be defined in column_definition, otherwise we had to detect the key type from the INDEX query and add it to the ALTER/ADD query.
- If a column changes from "NULL" to "NOT NULL" we generate an extra UPDATE query to prevent "Data truncated for column 'X' at row Y" errors.
- 'create_table'
- 'create_database'
- 'insert'
- 'update'
- 'drop_column'
- 'change_column'
- 'change_default'
- 'add_column'
- 'add_index'
- 'drop_index'
NOTE: collations and charset changes are ignored. It seems quite difficult to support this, and it seems to be best to handle this "manually".
Parameters:| array | $queries: | The list of queries for which the DB should be adjusted |
| array | $exclude_types: | Exclude query types (see list above). |
| boolean | $execute: | Execute generated queries? TODO: get this outta here!!!! (sooooo bloated!) |
API Tags:
| Return: | The generated queries. table_name => array of arrays (queries with keys 'queries' (array), 'note' (string) and 'type' (string)) There's usually just a single query in "queries", but in some cases additional queries are needed (e.g., 'UPDATE' before we can change "NULL" setting). |
| See: | http://dev.mysql.com/doc/refman/4.1/en/create-table.html |
Information Tags:
| Author: | Originally taken from Wordpress, heavily enhanced and modified by blueyed |
| Todo: | Handle COMMENT for tables?! |
|
Remove backticks around a field/table name.
"backtick" means "single backquote" (`)
Parameters:| string | $fieldname: | Field name |
|
Alter the DB schema to match the current expected one ($schema_queries).
Parameters:| boolean | $display: | Display what we've done? |
Information Tags:
| Todo: | if used by install only, then put it into the install folde!!! |
