Anton Shloma. Custom tables
-
Upload
drupalsib -
Category
Technology
-
view
58 -
download
4
Transcript of Anton Shloma. Custom tables
![Page 1: Anton Shloma. Custom tables](https://reader034.fdocuments.net/reader034/viewer/2022042818/55b626e6bb61ebea618b474b/html5/thumbnails/1.jpg)
Кастомные таблицы в Drupal 7Модули Schema, Data, Entity Construction Kit
Антон ШломаИнженер программист[email protected] Группа компаний i20
![Page 2: Anton Shloma. Custom tables](https://reader034.fdocuments.net/reader034/viewer/2022042818/55b626e6bb61ebea618b474b/html5/thumbnails/2.jpg)
Почему используют?Кастомные таблицы в Drupal 7
● Не нравится node● Не нравится taxonomy term● Вообще раздражает слово
bundle и entity● Я пишу на нативном PHP,
мне вообще не нужен Drupal
● Задумался о производительности
![Page 3: Anton Shloma. Custom tables](https://reader034.fdocuments.net/reader034/viewer/2022042818/55b626e6bb61ebea618b474b/html5/thumbnails/3.jpg)
Зачем нужно использовать?Кастомные таблицы в Drupal 7
● Нужны быстрые запросы● Нужно временное хранилище данных● Денормализация данных● Специфичный функционал
Разные задачи - разные подходы в решении
![Page 4: Anton Shloma. Custom tables](https://reader034.fdocuments.net/reader034/viewer/2022042818/55b626e6bb61ebea618b474b/html5/thumbnails/4.jpg)
НедостаткиКастомные таблицы в Drupal 7
● Возможно уже есть специальное решение для вашей задачи.
● Трудно дорабатывать, потеря данных.● Нет интеграции с другими модулями.● Больше времени на разработку● Проблема с переносом на другие
инстансы● Бесхозные таблицы захламляют БД.
![Page 5: Anton Shloma. Custom tables](https://reader034.fdocuments.net/reader034/viewer/2022042818/55b626e6bb61ebea618b474b/html5/thumbnails/5.jpg)
Как создавать?Кастомные таблицы в Drupal 7
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name (create_definition,...) [table_options] [partition_options]
![Page 6: Anton Shloma. Custom tables](https://reader034.fdocuments.net/reader034/viewer/2022042818/55b626e6bb61ebea618b474b/html5/thumbnails/6.jpg)
Как создавать?Кастомные таблицы в Drupal 7
Модуль Schemafunction hook_schema() { $schema['node'] = array( 'description' => 'The base table for nodes.', 'fields' => array( 'nid' => array( 'description' => 'The primary identifier for a node.', 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, ), ...
...'primary key' => array('nid'), ); return $schema;}
![Page 7: Anton Shloma. Custom tables](https://reader034.fdocuments.net/reader034/viewer/2022042818/55b626e6bb61ebea618b474b/html5/thumbnails/7.jpg)
Типы данныхDrupal 7 Schema API
type size MySQL type & size/range PostgreSQL type & size/range SQLite type
serial tiny tinyint, 1 B serial, 4 B integer
serial small smallint, 2 B serial, 4 B integer
serial medium mediumint, 3 B serial, 4 B integer
serial big bigint, 8 B bigserial, 8 B integer
serial normal int, 4 B serial, 4 B integer
int tiny tinyint, 1 B smallint, 2 B integer
int small smallint, 2 B smallint, 2 B integer
int medium mediumint, 3 B int, 4 B integer
int big bigint, 8 B bigint, 8 B integer
int normal int, 4 B int, 4 B integer
float tiny float, 4 B real, 6 digits floathttps://www.drupal.org/node/159605
![Page 8: Anton Shloma. Custom tables](https://reader034.fdocuments.net/reader034/viewer/2022042818/55b626e6bb61ebea618b474b/html5/thumbnails/8.jpg)
Модуль DataИнтеграция кастомных таблиц
● Управление таблицами● Интеграция с модулем features● Интеграция с модулем views● Relations● Экспорт схемы● API● Хуки
Reported installs: 8,970 sites currently report using this module.Downloads: 104,410
![Page 9: Anton Shloma. Custom tables](https://reader034.fdocuments.net/reader034/viewer/2022042818/55b626e6bb61ebea618b474b/html5/thumbnails/9.jpg)
Модуль DataИнтеграция кастомных таблиц
![Page 10: Anton Shloma. Custom tables](https://reader034.fdocuments.net/reader034/viewer/2022042818/55b626e6bb61ebea618b474b/html5/thumbnails/10.jpg)
Модуль DataИнтеграция кастомных таблиц
![Page 11: Anton Shloma. Custom tables](https://reader034.fdocuments.net/reader034/viewer/2022042818/55b626e6bb61ebea618b474b/html5/thumbnails/11.jpg)
Модуль DataИнтеграция кастомных таблиц
![Page 12: Anton Shloma. Custom tables](https://reader034.fdocuments.net/reader034/viewer/2022042818/55b626e6bb61ebea618b474b/html5/thumbnails/12.jpg)
Модуль DataИнтеграция кастомных таблиц
![Page 13: Anton Shloma. Custom tables](https://reader034.fdocuments.net/reader034/viewer/2022042818/55b626e6bb61ebea618b474b/html5/thumbnails/13.jpg)
Модуль DataИнтеграция кастомных таблиц
![Page 14: Anton Shloma. Custom tables](https://reader034.fdocuments.net/reader034/viewer/2022042818/55b626e6bb61ebea618b474b/html5/thumbnails/14.jpg)
Модуль Entity Construction KitКастомные entity
● Управление properties● Управление fields● Редактирование, добавление● Интеграция с views● View моды● Интеграция с features● Многое другое
Reported installs: 9,756 sites currently report using this module. View usage statistics.Downloads: 136,785
![Page 15: Anton Shloma. Custom tables](https://reader034.fdocuments.net/reader034/viewer/2022042818/55b626e6bb61ebea618b474b/html5/thumbnails/15.jpg)
Модуль Entity Construction KitКастомные entity
![Page 16: Anton Shloma. Custom tables](https://reader034.fdocuments.net/reader034/viewer/2022042818/55b626e6bb61ebea618b474b/html5/thumbnails/16.jpg)
Модуль Entity Construction KitКастомные entity
![Page 17: Anton Shloma. Custom tables](https://reader034.fdocuments.net/reader034/viewer/2022042818/55b626e6bb61ebea618b474b/html5/thumbnails/17.jpg)
Модуль Entity Construction KitКастомные entity
![Page 18: Anton Shloma. Custom tables](https://reader034.fdocuments.net/reader034/viewer/2022042818/55b626e6bb61ebea618b474b/html5/thumbnails/18.jpg)
Модуль Entity Construction KitКастомные entity
![Page 19: Anton Shloma. Custom tables](https://reader034.fdocuments.net/reader034/viewer/2022042818/55b626e6bb61ebea618b474b/html5/thumbnails/19.jpg)
Модуль Entity Construction KitКастомные entity
![Page 20: Anton Shloma. Custom tables](https://reader034.fdocuments.net/reader034/viewer/2022042818/55b626e6bb61ebea618b474b/html5/thumbnails/20.jpg)
Модуль Entity Construction KitКастомные entity
![Page 21: Anton Shloma. Custom tables](https://reader034.fdocuments.net/reader034/viewer/2022042818/55b626e6bb61ebea618b474b/html5/thumbnails/21.jpg)
Модуль Entity Construction KitКастомные entity
![Page 22: Anton Shloma. Custom tables](https://reader034.fdocuments.net/reader034/viewer/2022042818/55b626e6bb61ebea618b474b/html5/thumbnails/22.jpg)
Модуль Entity Construction KitКастомные entity
![Page 23: Anton Shloma. Custom tables](https://reader034.fdocuments.net/reader034/viewer/2022042818/55b626e6bb61ebea618b474b/html5/thumbnails/23.jpg)
Модуль Entity Construction KitКастомные entity
![Page 24: Anton Shloma. Custom tables](https://reader034.fdocuments.net/reader034/viewer/2022042818/55b626e6bb61ebea618b474b/html5/thumbnails/24.jpg)
Модуль Entity Construction KitКастомные entity
![Page 25: Anton Shloma. Custom tables](https://reader034.fdocuments.net/reader034/viewer/2022042818/55b626e6bb61ebea618b474b/html5/thumbnails/25.jpg)
Спасибо за вниманиеВопросы?
Антон ШломаИнженер программист[email protected] Группа компаний i20http://i20.biz