| @@ 2177-2204 (lines=28) @@ | ||
| 2174 | * |
|
| 2175 | * @see Alpha\Model\ActiveRecordProviderInterface::createUniqueIndex() |
|
| 2176 | */ |
|
| 2177 | public function createUniqueIndex($attribute1Name, $attribute2Name = '', $attribute3Name = '') |
|
| 2178 | { |
|
| 2179 | self::$logger->debug('>>createUniqueIndex(attribute1Name=['.$attribute1Name.'], attribute2Name=['.$attribute2Name.'], attribute3Name=['.$attribute3Name.'])'); |
|
| 2180 | ||
| 2181 | if ($attribute2Name != '' && $attribute3Name != '') { |
|
| 2182 | $sqlQuery = 'CREATE UNIQUE INDEX '.$attribute1Name.'_'.$attribute2Name.'_'.$attribute3Name.'_unq_idx ON '.$this->BO->getTableName().' ('.$attribute1Name.','.$attribute2Name.','.$attribute3Name.');'; |
|
| 2183 | } |
|
| 2184 | ||
| 2185 | if ($attribute2Name != '' && $attribute3Name == '') { |
|
| 2186 | $sqlQuery = 'CREATE UNIQUE INDEX '.$attribute1Name.'_'.$attribute2Name.'_unq_idx ON '.$this->BO->getTableName().' ('.$attribute1Name.','.$attribute2Name.');'; |
|
| 2187 | } |
|
| 2188 | ||
| 2189 | if ($attribute2Name == '' && $attribute3Name == '') { |
|
| 2190 | $sqlQuery = 'CREATE UNIQUE INDEX '.$attribute1Name.'_unq_idx ON '.$this->BO->getTableName().' ('.$attribute1Name.');'; |
|
| 2191 | } |
|
| 2192 | ||
| 2193 | $this->BO->setLastQuery($sqlQuery); |
|
| 2194 | ||
| 2195 | $result = self::getConnection()->query($sqlQuery); |
|
| 2196 | ||
| 2197 | if ($result) { |
|
| 2198 | self::$logger->debug('Successfully created the unique index on ['.$this->BO->getTableName().']'); |
|
| 2199 | } else { |
|
| 2200 | throw new FailedIndexCreateException('Failed to create the unique index on ['.$this->BO->getTableName().'], error is ['.self::getConnection()->error.']'); |
|
| 2201 | } |
|
| 2202 | ||
| 2203 | self::$logger->debug('<<createUniqueIndex'); |
|
| 2204 | } |
|
| 2205 | ||
| 2206 | /** |
|
| 2207 | * (non-PHPdoc). |
|
| @@ 2099-2126 (lines=28) @@ | ||
| 2096 | * |
|
| 2097 | * @see Alpha\Model\ActiveRecordProviderInterface::createUniqueIndex() |
|
| 2098 | */ |
|
| 2099 | public function createUniqueIndex($attribute1Name, $attribute2Name = '', $attribute3Name = '') |
|
| 2100 | { |
|
| 2101 | self::$logger->debug('>>createUniqueIndex(attribute1Name=['.$attribute1Name.'], attribute2Name=['.$attribute2Name.'], attribute3Name=['.$attribute3Name.'])'); |
|
| 2102 | ||
| 2103 | if ($attribute2Name != '' && $attribute3Name != '') { |
|
| 2104 | $sqlQuery = 'CREATE UNIQUE INDEX IF NOT EXISTS '.$attribute1Name.'_'.$attribute2Name.'_'.$attribute3Name.'_unq_idx ON '.$this->BO->getTableName().' ('.$attribute1Name.','.$attribute2Name.','.$attribute3Name.');'; |
|
| 2105 | } |
|
| 2106 | ||
| 2107 | if ($attribute2Name != '' && $attribute3Name == '') { |
|
| 2108 | $sqlQuery = 'CREATE UNIQUE INDEX IF NOT EXISTS '.$attribute1Name.'_'.$attribute2Name.'_unq_idx ON '.$this->BO->getTableName().' ('.$attribute1Name.','.$attribute2Name.');'; |
|
| 2109 | } |
|
| 2110 | ||
| 2111 | if ($attribute2Name == '' && $attribute3Name == '') { |
|
| 2112 | $sqlQuery = 'CREATE UNIQUE INDEX IF NOT EXISTS '.$attribute1Name.'_unq_idx ON '.$this->BO->getTableName().' ('.$attribute1Name.');'; |
|
| 2113 | } |
|
| 2114 | ||
| 2115 | $this->BO->setLastQuery($sqlQuery); |
|
| 2116 | ||
| 2117 | $result = self::getConnection()->query($sqlQuery); |
|
| 2118 | ||
| 2119 | if ($result) { |
|
| 2120 | self::$logger->debug('Successfully created the unique index on ['.$this->BO->getTableName().']'); |
|
| 2121 | } else { |
|
| 2122 | throw new FailedIndexCreateException('Failed to create the unique index on ['.$this->BO->getTableName().'], error is ['.self::getConnection()->error.']'); |
|
| 2123 | } |
|
| 2124 | ||
| 2125 | self::$logger->debug('<<createUniqueIndex'); |
|
| 2126 | } |
|
| 2127 | ||
| 2128 | /** |
|
| 2129 | * (non-PHPdoc). |
|