--
-- VIEW application-view
--
-DROP VIEW IF EXISTS `application-view`;
CREATE VIEW `application-view` AS SELECT
`application`.`id` AS `id`,
`application-token`.`uid` AS `uid`,
--
-- VIEW post-user-view
--
-DROP VIEW IF EXISTS `post-user-view`;
CREATE VIEW `post-user-view` AS SELECT
`post-user`.`id` AS `id`,
`post-user`.`id` AS `post-user-id`,
--
-- VIEW post-thread-user-view
--
-DROP VIEW IF EXISTS `post-thread-user-view`;
CREATE VIEW `post-thread-user-view` AS SELECT
`post-user`.`id` AS `id`,
`post-user`.`id` AS `post-user-id`,
--
-- VIEW post-view
--
-DROP VIEW IF EXISTS `post-view`;
CREATE VIEW `post-view` AS SELECT
`item-uri`.`uri` AS `uri`,
`post`.`uri-id` AS `uri-id`,
--
-- VIEW post-thread-view
--
-DROP VIEW IF EXISTS `post-thread-view`;
CREATE VIEW `post-thread-view` AS SELECT
`item-uri`.`uri` AS `uri`,
`post-thread`.`uri-id` AS `uri-id`,
--
-- VIEW category-view
--
-DROP VIEW IF EXISTS `category-view`;
CREATE VIEW `category-view` AS SELECT
`post-category`.`uri-id` AS `uri-id`,
`post-category`.`uid` AS `uid`,
--
-- VIEW collection-view
--
-DROP VIEW IF EXISTS `collection-view`;
CREATE VIEW `collection-view` AS SELECT
`post-collection`.`uri-id` AS `uri-id`,
`post-collection`.`type` AS `type`,
--
-- VIEW tag-view
--
-DROP VIEW IF EXISTS `tag-view`;
CREATE VIEW `tag-view` AS SELECT
`post-tag`.`uri-id` AS `uri-id`,
`post-tag`.`type` AS `type`,
--
-- VIEW network-item-view
--
-DROP VIEW IF EXISTS `network-item-view`;
CREATE VIEW `network-item-view` AS SELECT
`post-user`.`uri-id` AS `uri-id`,
`parent-post`.`id` AS `parent`,
--
-- VIEW network-thread-view
--
-DROP VIEW IF EXISTS `network-thread-view`;
CREATE VIEW `network-thread-view` AS SELECT
`post-thread-user`.`uri-id` AS `uri-id`,
`parent-post`.`id` AS `parent`,
--
-- VIEW owner-view
--
-DROP VIEW IF EXISTS `owner-view`;
CREATE VIEW `owner-view` AS SELECT
`contact`.`id` AS `id`,
`contact`.`uid` AS `uid`,
--
-- VIEW account-view
--
-DROP VIEW IF EXISTS `account-view`;
CREATE VIEW `account-view` AS SELECT
`contact`.`id` AS `id`,
`contact`.`url` AS `url`,
--
-- VIEW account-user-view
--
-DROP VIEW IF EXISTS `account-user-view`;
CREATE VIEW `account-user-view` AS SELECT
`ucontact`.`id` AS `id`,
`contact`.`id` AS `pid`,
--
-- VIEW pending-view
--
-DROP VIEW IF EXISTS `pending-view`;
CREATE VIEW `pending-view` AS SELECT
`register`.`id` AS `id`,
`register`.`hash` AS `hash`,
--
-- VIEW tag-search-view
--
-DROP VIEW IF EXISTS `tag-search-view`;
CREATE VIEW `tag-search-view` AS SELECT
`post-tag`.`uri-id` AS `uri-id`,
`post-user`.`uid` AS `uid`,
--
-- VIEW workerqueue-view
--
-DROP VIEW IF EXISTS `workerqueue-view`;
CREATE VIEW `workerqueue-view` AS SELECT
`process`.`pid` AS `pid`,
`workerqueue`.`priority` AS `priority`
--
-- VIEW profile_field-view
--
-DROP VIEW IF EXISTS `profile_field-view`;
CREATE VIEW `profile_field-view` AS SELECT
`profile_field`.`id` AS `id`,
`profile_field`.`uid` AS `uid`,
/**
* Select rows from a table and fills an array with the data
*
- * @param string|array $table Table name or array [schema => table]
- * @param array $fields Array of selected fields, empty for all
- * @param array $condition Array of fields for condition
- * @param array $params Array of several parameters
+ * @param string $table Table name or array [schema => table]
+ * @param array $fields Array of selected fields, empty for all
+ * @param array $condition Array of fields for condition
+ * @param array $params Array of several parameters
*
* @return array Data array
* @throws \Exception
* @see self::select
*/
- public static function selectToArray($table, array $fields = [], array $condition = [], array $params = [])
+ public static function selectToArray(string $table, array $fields = [], array $condition = [], array $params = [])
{
return DI::dba()->selectToArray($table, $fields, $condition, $params);
}
'deliverq', 'dsprphotoq', 'ffinder', 'sign', 'spam', 'term', 'user-item', 'thread', 'item', 'challenge',
'auth_codes', 'tokens', 'clients', 'profile_check', 'host'];
- $tables = DBA::selectToArray(['INFORMATION_SCHEMA' => 'TABLES'], ['TABLE_NAME'],
+ $tables = DBA::selectToArray('INFORMATION_SCHEMA.TABLES', ['TABLE_NAME'],
['TABLE_SCHEMA' => DBA::databaseName(), 'TABLE_TYPE' => 'BASE TABLE']);
if (empty($tables)) {
public static function convertToInnoDB()
{
$tables = DBA::selectToArray(
- ['information_schema' => 'tables'],
+ 'information_schema.tables',
['table_name'],
['engine' => 'MyISAM', 'table_schema' => DBA::databaseName()]
);
$tables = array_merge($tables, DBA::selectToArray(
- ['information_schema' => 'tables'],
+ 'information_schema.tables',
['table_name'],
['engine' => 'InnoDB', 'ROW_FORMAT' => ['COMPACT', 'REDUNDANT'], 'table_schema' => DBA::databaseName()]
));
// This query doesn't seem to be executable as a prepared statement
$indexes = DBA::toArray(DBA::p("SHOW INDEX FROM " . DBA::quoteIdentifier($table)));
- $fields = DBA::selectToArray(['INFORMATION_SCHEMA' => 'COLUMNS'],
+ $fields = DBA::selectToArray('INFORMATION_SCHEMA.COLUMNS',
['COLUMN_NAME', 'COLUMN_TYPE', 'IS_NULLABLE', 'COLUMN_DEFAULT', 'EXTRA',
'COLUMN_KEY', 'COLLATION_NAME', 'COLUMN_COMMENT'],
["`TABLE_SCHEMA` = ? AND `TABLE_NAME` = ?",
DBA::databaseName(), $table]);
- $foreign_keys = DBA::selectToArray(['INFORMATION_SCHEMA' => 'KEY_COLUMN_USAGE'],
+ $foreign_keys = DBA::selectToArray('INFORMATION_SCHEMA.KEY_COLUMN_USAGE',
['COLUMN_NAME', 'CONSTRAINT_NAME', 'REFERENCED_TABLE_NAME', 'REFERENCED_COLUMN_NAME'],
["`TABLE_SCHEMA` = ? AND `TABLE_NAME` = ? AND `REFERENCED_TABLE_SCHEMA` IS NOT NULL",
DBA::databaseName(), $table]);
- $table_status = DBA::selectFirst(['INFORMATION_SCHEMA' => 'TABLES'],
+ $table_status = DBA::selectFirst('INFORMATION_SCHEMA.TABLES',
['ENGINE', 'TABLE_COLLATION', 'TABLE_COMMENT'],
["`TABLE_SCHEMA` = ? AND `TABLE_NAME` = ?",
DBA::databaseName(), $table]);
* @return boolean Does the table exist?
* @throws Exception
*/
- public static function existsColumn($table, $columns = [])
+ public static function existsColumn(string $table, array $columns = []): bool
{
if (empty($table)) {
return false;
/**
* Retrieve a single record from a table and returns it in an associative array
*
- * @param string|array $table
- * @param array $fields
- * @param array $condition
- * @param array $params
+ * @param string $table Table name or array [schema => table]
+ * @param array $fields Array of selected fields, empty for all
+ * @param array $condition Array of fields for condition
+ * @param array $params Array of several parameters
*
* @return bool|array
* @throws \Exception
* @see $this->select
*/
- public function selectFirst($table, array $fields = [], array $condition = [], array $params = [])
+ public function selectFirst(string $table, array $fields = [], array $condition = [], array $params = [])
{
$params['limit'] = 1;
$result = $this->select($table, $fields, $condition, $params);
/**
* Select rows from a table and fills an array with the data
*
- * @param string|array $table Table name or array [schema => table]
- * @param array $fields Array of selected fields, empty for all
- * @param array $condition Array of fields for condition
- * @param array $params Array of several parameters
- *
+ * @param string $table Table name or array [schema => table]
+ * @param array $fields Array of selected fields, empty for all
+ * @param array $condition Array of fields for condition
+ * @param array $params Array of several parameters
* @return array Data array
* @throws \Exception
* @see self::select
*/
- public function selectToArray($table, array $fields = [], array $condition = [], array $params = [])
+ public function selectToArray(string $table, array $fields = [], array $condition = [], array $params = [])
{
return $this->toArray($this->select($table, $fields, $condition, $params));
}
*/
private static function isView(string $view): bool
{
- $status = DBA::selectFirst(['INFORMATION_SCHEMA' => 'TABLES'], ['TABLE_TYPE'],
+ $status = DBA::selectFirst('INFORMATION_SCHEMA.TABLES', ['TABLE_TYPE'],
['TABLE_SCHEMA' => DBA::databaseName(), 'TABLE_NAME' => $view]);
if (empty($status['TABLE_TYPE'])) {
*/
private static function isTable(string $table): bool
{
- $status = DBA::selectFirst(['INFORMATION_SCHEMA' => 'TABLES'], ['TABLE_TYPE'],
+ $status = DBA::selectFirst('INFORMATION_SCHEMA.TABLES', ['TABLE_TYPE'],
['TABLE_SCHEMA' => DBA::databaseName(), 'TABLE_NAME' => $table]);
if (empty($status['TABLE_TYPE'])) {