protected function _getPortableTableIndexesList($tableIndexes, $tableName = null) { $indexes = array(); foreach ($tableIndexes as $k) { $k['primary'] = (bool) $k['primary']; $indexes[] = $k; } return parent::_getPortableTableIndexesList($indexes, $tableName); }
protected function _getPortableTableIndexesList($tableIndexes, $tableName = null) { foreach ($tableIndexes as $k => $v) { $v = array_change_key_case($v, CASE_LOWER); if ($v['key_name'] == 'PRIMARY') { $v['primary'] = true; } else { $v['primary'] = false; } $tableIndexes[$k] = $v; } return parent::_getPortableTableIndexesList($tableIndexes, $tableName); }
/** * @license New BSD License * @link http://ezcomponents.org/docs/api/trunk/DatabaseSchema/ezcDbSchemaPgsqlReader.html * @param array $tableIndexes * @param string $tableName * @return array */ protected function _getPortableTableIndexesList($tableIndexes, $tableName = null) { $indexBuffer = array(); foreach ($tableIndexes as $tableIndex) { $tableIndex = \array_change_key_case($tableIndex, CASE_LOWER); $keyName = strtolower($tableIndex['name']); if (strtolower($tableIndex['is_primary']) == "p") { $keyName = 'primary'; $buffer['primary'] = true; $buffer['non_unique'] = false; } else { $buffer['primary'] = false; $buffer['non_unique'] = $tableIndex['is_unique'] == 0 ? true : false; } $buffer['key_name'] = $keyName; $buffer['column_name'] = $tableIndex['column_name']; $indexBuffer[] = $buffer; } return parent::_getPortableTableIndexesList($indexBuffer, $tableName); }
/** * {@inheritdoc} */ protected function _getPortableTableIndexesList($tableIndexRows, $tableName = null) { foreach ($tableIndexRows as &$tableIndexRow) { $tableIndexRow = array_change_key_case($tableIndexRow, \CASE_LOWER); $tableIndexRow['primary'] = (bool) $tableIndexRow['primary']; } return parent::_getPortableTableIndexesList($tableIndexRows, $tableName); }
/** * @license New BSD License * @link http://ezcomponents.org/docs/api/trunk/DatabaseSchema/ezcDbSchemaPgsqlReader.html * @param array $tableIndexes * @param string $tableName * @return array */ protected function _getPortableTableIndexesList($tableIndexes, $tableName = null) { $buffer = array(); foreach ($tableIndexes as $row) { $colNumbers = explode(' ', $row['indkey']); $colNumbersSql = 'IN (' . join(' ,', $colNumbers) . ' )'; $columnNameSql = "SELECT attnum, attname FROM pg_attribute\n WHERE attrelid={$row['indrelid']} AND attnum {$colNumbersSql} ORDER BY attnum ASC;"; $stmt = $this->_conn->executeQuery($columnNameSql); $indexColumns = $stmt->fetchAll(); // required for getting the order of the columns right. foreach ($colNumbers as $colNum) { foreach ($indexColumns as $colRow) { if ($colNum == $colRow['attnum']) { $buffer[] = array('key_name' => $row['relname'], 'column_name' => trim($colRow['attname']), 'non_unique' => !$row['indisunique'], 'primary' => $row['indisprimary']); } } } } return parent::_getPortableTableIndexesList($buffer, $tableName); }
/** * @license New BSD License * @link http://ezcomponents.org/docs/api/trunk/DatabaseSchema/ezcDbSchemaPgsqlReader.html * @param array $tableIndexes * @param string $tableName * @return array */ protected function _getPortableTableIndexesList($tableIndexes, $tableName = null) { $indexBuffer = array(); // fetch primary $stmt = $this->_conn->executeQuery("PRAGMA TABLE_INFO ('{$tableName}')"); $indexArray = $stmt->fetchAll(\PDO::FETCH_ASSOC); foreach ($indexArray as $indexColumnRow) { if ($indexColumnRow['pk'] == "1") { $indexBuffer[] = array('key_name' => 'primary', 'primary' => true, 'non_unique' => false, 'column_name' => $indexColumnRow['name']); } } // fetch regular indexes foreach ($tableIndexes as $tableIndex) { // Ignore indexes with reserved names, e.g. autoindexes if (strpos($tableIndex['name'], 'sqlite_') !== 0) { $keyName = $tableIndex['name']; $idx = array(); $idx['key_name'] = $keyName; $idx['primary'] = false; $idx['non_unique'] = $tableIndex['unique'] ? false : true; $stmt = $this->_conn->executeQuery("PRAGMA INDEX_INFO ( '{$keyName}' )"); $indexArray = $stmt->fetchAll(\PDO::FETCH_ASSOC); foreach ($indexArray as $indexColumnRow) { $idx['column_name'] = $indexColumnRow['name']; $indexBuffer[] = $idx; } } } return parent::_getPortableTableIndexesList($indexBuffer, $tableName); }
/** * @license New BSD License * @link http://ezcomponents.org/docs/api/trunk/DatabaseSchema/ezcDbSchemaPgsqlReader.html * @param array $tableIndexes * @param string $tableName * @return array */ protected function _getPortableTableIndexesList($tableIndexes, $tableName = null) { $indexBuffer = array(); // fetch primary $stmt = $this->_conn->execute("PRAGMA TABLE_INFO ('{$tableName}')"); $indexArray = $stmt->fetchAll(\Doctrine\DBAL\Connection::FETCH_ASSOC); foreach ($indexArray as $indexColumnRow) { if ($indexColumnRow['pk'] == "1") { $indexBuffer[] = array('key_name' => 'primary', 'primary' => true, 'non_unique' => false, 'column_name' => $indexColumnRow['name']); } } // fetch regular indexes foreach ($tableIndexes as $tableIndex) { $keyName = $tableIndex['name']; $idx = array(); $idx['key_name'] = $keyName; $idx['primary'] = false; $idx['non_unique'] = $tableIndex['unique'] ? false : true; $stmt = $this->_conn->execute("PRAGMA INDEX_INFO ( '{$keyName}' )"); $indexArray = $stmt->fetchAll(\Doctrine\DBAL\Connection::FETCH_ASSOC); foreach ($indexArray as $indexColumnRow) { $idx['column_name'] = $indexColumnRow['name']; $indexBuffer[] = $idx; } } return parent::_getPortableTableIndexesList($indexBuffer, $tableName); }