update_sql
Хочешь помочь с переводом? Это очень просто и быстро. Лишь зарегистрируйся, и можешь тут же начать переводить.
includes/database.inc, строка 63
- Версии
- 5 – 6
update_sql($sql)
Выполняет SQL-запрос и возвращает статус результата. Используется преимущественно в hook_update_N()
и остальных функциях инсталяции/обновления модулей.
Параметры
$sql
Строка содержащая полный SQL запрос. '%'-заменители не поддерживаются.
Возвращаемое значение
Ассоциативный массив результата выполнения запроса с ключами:
'success'
Успешно ли выполнен запрос —TRUE
илиFALSE
.'query'
Выполенный SQL запрос (пропущенный черезcheck_plain()
).
Perform an SQL query and return success or failure.
Parameters
$sql A string containing a complete SQL query. %-substitution parameters are not supported.
Return value
An array containing the keys: success: a boolean indicating whether the query succeeded query: the SQL query executed, passed through check_plain()
Связанные темы
- Уровень абстракции базы данных
- Позволяет выполнять один программный код на разных СУБД.
▾ 48 функции вызывают update_sql()
- book_update_6000 in modules/book/book.install
- Drupal 5.x to 6.x update.
- comment_update_6001 in modules/comment/comment.install
- db_add_column in ./update.php
- Add a column to a database using syntax appropriate for PostgreSQL. Save result of SQL commands in $ret array.
- db_add_field in includes/database.mysql-common.inc
- Добавляет новое поле в таблицу.
- db_add_index in includes/database.mysql-common.inc
- Добавляет индекс.
- db_add_primary_key in includes/database.mysql-common.inc
- Добавляет первичный ключ.
- db_add_unique_key in includes/database.mysql-common.inc
- Добавляет уникальный ключ.
- db_change_column in ./update.php
- Change a column definition using syntax appropriate for PostgreSQL. Save result of SQL commands in $ret array.
- db_change_field in includes/database.mysql-common.inc
- Меняет определение поля.
- db_create_table in includes/database.inc
- Создает новую таблицу из описания таблицы в нотации Друпала.
- db_drop_field in includes/database.mysql-common.inc
- Удаляет поле в таблице БД.
- db_drop_index in includes/database.mysql-common.inc
- Удаляет индекс в таблице БД.
- db_drop_primary_key in includes/database.mysql-common.inc
- Удаляет первичный ключ.
- db_drop_table in includes/database.mysql-common.inc
- Удаляет таблицу из БД.
- db_drop_unique_key in includes/database.mysql-common.inc
- Удаляет уникальный ключ.
- db_field_set_default in includes/database.mysql-common.inc
- Устанавливает значение по умолчанию для поля таблицы БД.
- db_field_set_no_default in includes/database.mysql-common.inc
- Убирает у поля значение по умолчанию.
- db_rename_table in includes/database.mysql-common.inc
- Переименовывает таблицу БД.
- hook_update_N in developer/hooks/install.php
- Производит обновление таблиц БД, необходимое для единичного обновления модуля.
- locale_update_6000 in modules/locale/locale.install
- {locales_meta} table became {languages}.
- locale_update_6001 in modules/locale/locale.install
- Change locale column to language. The language column is added by update_fix_d6_requirements() in update.php to avoid a large number of error messages from update.php. All we need to do here is copy locale to language and then drop locale.
- locale_update_6002 in modules/locale/locale.install
- Remove empty translations, we don't need these anymore.
- locale_update_6003 in modules/locale/locale.install
- Prune strings with no translations (will be automatically re-registered if still in use)
- statistics_update_1000 in modules/statistics/statistics.install
- Changes session ID field to VARCHAR(64) to add support for SHA-1 hashes.
- system_update_6000 in modules/system/system.install
- Remove auto_increment from {boxes} to allow adding custom blocks with visibility settings.
- system_update_6005 in modules/system/system.install
- Add language to url_alias table and modify indexes.
- system_update_6006 in modules/system/system.install
- Drop useless indices on node_counter table.
- system_update_6007 in modules/system/system.install
- Change the severity column in the watchdog table to the new values.
- system_update_6008 in modules/system/system.install
- Add info files to themes. The info and owner columns are added by update_fix_d6_requirements() in update.php to avoid a large number of error messages from update.php. All we need to do here is copy description to owner and then drop description.
- system_update_6009 in modules/system/system.install
- The PHP filter is now a separate module.
- system_update_6011 in modules/system/system.install
- Add language support to nodes
- system_update_6015 in modules/system/system.install
- Add the form cache table.
- system_update_6016 in modules/system/system.install
- Make {node}'s primary key be nid, change nid,vid to a unique key. Add primary keys to block, filters, flood, permission, and term_relation.
- system_update_6018 in modules/system/system.install
- Add HTML corrector to HTML formats or replace the old module if it was in use.
- system_update_6019 in modules/system/system.install
- Reconcile small differences in the previous, manually created mysql and pgsql schemas so they are the same and can be represented by a single schema structure.
- system_update_6021 in modules/system/system.install
- Migrate the menu items from the old menu system to the new menu_links table.
- system_update_6022 in modules/system/system.install
- Update files tables to associate files to a uid by default instead of a nid. Rename file_revisions to upload since it should only be used by the upload module used by upload to link files to nodes.
- system_update_6034 in modules/system/system.install
- Rename permission 'administer access control' to 'administer permissions'.
- system_update_6036 in modules/system/system.install
- Change the search schema and indexing.
- system_update_6037 in modules/system/system.install
- Create consistent empty region for disabled blocks.
- system_update_6038 in modules/system/system.install
- Ensure that 'Account' is not used as a Profile category.
- system_update_6039 in modules/system/system.install
- Rename permissions 'edit foo content' to 'edit any foo content'. Also update poll module permission 'create polls' to 'create poll content'.
- system_update_6041 in modules/system/system.install
- Change forum vocabulary not to be required by default and set the weight of the forum.module 1 higher than the taxonomy.module.
- system_update_6044 in modules/system/system.install
- RC1 to RC2 index cleanup.
- system_update_6045 in modules/system/system.install
- Update blog, book and locale module permissions.
- system_update_6047 in modules/system/system.install
- Fix cache mode for blocks inserted in system_install() in fresh installs of previous RC.
- system_update_6051 in modules/system/system.install
- Create a signature_format column.
- update_fix_compatibility in ./update.php
- Disable anything in the {system} table that is not compatible with the current version of Drupal core.
Код
<?php
function update_sql($sql) {
$result = db_query($sql, true);
return array('success' => $result !== FALSE, 'query' => check_plain($sql));
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии