const ATTR_MAX_COLUMN_LEN = 18;
const ATTR_FIELD_CASE = 102;
- const ATTR_IDXNAME_FORMAT = 103;
const ATTR_CMPNAME_FORMAT = 118;
const ATTR_DBNAME_FORMAT = 117;
const ATTR_TBLCLASS_FORMAT = 119;
- const ATTR_TBLNAME_FORMAT = 120;
const ATTR_EXPORT = 140;
const ATTR_DECIMAL_PLACES = 141;
if ($value != 0 && $value != CASE_LOWER && $value != CASE_UPPER)
throw new IPF_ORM_Exception('Field case attribute should be either 0, CASE_LOWER or CASE_UPPER constant.');
break;
- case IPF_ORM::ATTR_IDXNAME_FORMAT:
- case IPF_ORM::ATTR_TBLNAME_FORMAT:
- if ($this instanceof IPF_ORM_Table) {
- throw new IPF_ORM_Exception('index name format attributes cannot be set'
- . 'at table level (only at connection or global level).');
- }
- break;
default:
throw new IPF_ORM_Exception("Unknown attribute.");
}
'string' => ''
);
+ protected function getIndexName($name)
+ {
+ return $name . '_idx';
+ }
+
public function dropDatabase($database)
{
$this->conn->execute($this->dropDatabaseSql($database));
public function dropIndexSql($table, $name)
{
- $name = $this->conn->quoteIdentifier($this->conn->formatter->getIndexName($name));
+ $name = $this->conn->quoteIdentifier($this->getIndexName($name));
return 'DROP INDEX ' . $name;
}
public function createConstraintSql($table, $name, $definition)
{
$table = $this->conn->quoteIdentifier($table);
- $name = $this->conn->quoteIdentifier($this->conn->formatter->getIndexName($name));
+ $name = $this->conn->quoteIdentifier($this->getIndexName($name));
$query = 'ALTER TABLE ' . $table . ' ADD CONSTRAINT ' . $name;
if (isset($definition['primary']) && $definition['primary']) {
public function createIndexSql($table, $name, array $definition)
{
- $table = $table;
- $name = $this->conn->formatter->getIndexName($name);
- $name = $this->conn->quoteIdentifier($name);
+ $name = $this->conn->quoteIdentifier($this->getIndexName($name));
$type = '';
if (isset($definition['type'])) {
switch (strtolower($definition['type'])) {
public function getIndexDeclaration($name, array $definition)
{
- $name = $this->conn->formatter->getIndexName($name);
+ $name = $this->getIndexName($name);
$type = '';
if (isset($definition['type'])) {
switch (strtolower($definition['type'])) {
public function dropIndexSql($table, $name)
{
$table = $this->conn->quoteIdentifier($table);
- $name = $this->conn->quoteIdentifier($this->conn->formatter->getIndexName($name));
+ $name = $this->conn->quoteIdentifier($this->getIndexName($name));
return 'DROP INDEX ' . $name . ' ON ' . $table;
}
}
return $text;
}
-
- public function getIndexName($idx)
- {
- return sprintf($this->conn->getAttribute(IPF_ORM::ATTR_IDXNAME_FORMAT),
- preg_replace('/[^a-z0-9_\$]/i', '_', $idx));
- }
-
- public function getTableName($table)
- {
- return sprintf($this->conn->getAttribute(IPF_ORM::ATTR_TBLNAME_FORMAT),
- $table);
- }
}
{
$this->attributes = array(
IPF_ORM::ATTR_LOAD_REFERENCES => true,
- IPF_ORM::ATTR_IDXNAME_FORMAT => "%s_idx",
- IPF_ORM::ATTR_TBLNAME_FORMAT => "%s",
IPF_ORM::ATTR_PORTABILITY => IPF_ORM::PORTABILITY_ALL,
IPF_ORM::ATTR_EXPORT => IPF_ORM::EXPORT_ALL,
IPF_ORM::ATTR_DECIMAL_PLACES => 2,
public function setTableName($tableName)
{
- $this->setOption('tableName', $this->_conn->formatter->getTableName($tableName));
+ $this->setOption('tableName', $tableName);
}
public function getTemplate($template)