| @@ 2174-2201 (lines=28) @@ | ||
| 2171 | * |
|
| 2172 | * @see Alpha\Model\ActiveRecordProviderInterface::createUniqueIndex() |
|
| 2173 | */ |
|
| 2174 | public function createUniqueIndex($attribute1Name, $attribute2Name = '', $attribute3Name = '') |
|
| 2175 | { |
|
| 2176 | self::$logger->debug('>>createUniqueIndex(attribute1Name=['.$attribute1Name.'], attribute2Name=['.$attribute2Name.'], attribute3Name=['.$attribute3Name.'])'); |
|
| 2177 | ||
| 2178 | if ($attribute2Name != '' && $attribute3Name != '') { |
|
| 2179 | $sqlQuery = 'CREATE UNIQUE INDEX '.$attribute1Name.'_'.$attribute2Name.'_'.$attribute3Name.'_unq_idx ON '.$this->BO->getTableName().' ('.$attribute1Name.','.$attribute2Name.','.$attribute3Name.');'; |
|
| 2180 | } |
|
| 2181 | ||
| 2182 | if ($attribute2Name != '' && $attribute3Name == '') { |
|
| 2183 | $sqlQuery = 'CREATE UNIQUE INDEX '.$attribute1Name.'_'.$attribute2Name.'_unq_idx ON '.$this->BO->getTableName().' ('.$attribute1Name.','.$attribute2Name.');'; |
|
| 2184 | } |
|
| 2185 | ||
| 2186 | if ($attribute2Name == '' && $attribute3Name == '') { |
|
| 2187 | $sqlQuery = 'CREATE UNIQUE INDEX '.$attribute1Name.'_unq_idx ON '.$this->BO->getTableName().' ('.$attribute1Name.');'; |
|
| 2188 | } |
|
| 2189 | ||
| 2190 | $this->BO->setLastQuery($sqlQuery); |
|
| 2191 | ||
| 2192 | $result = self::getConnection()->query($sqlQuery); |
|
| 2193 | ||
| 2194 | if ($result) { |
|
| 2195 | self::$logger->debug('Successfully created the unique index on ['.$this->BO->getTableName().']'); |
|
| 2196 | } else { |
|
| 2197 | throw new FailedIndexCreateException('Failed to create the unique index on ['.$this->BO->getTableName().'], error is ['.self::getConnection()->error.']'); |
|
| 2198 | } |
|
| 2199 | ||
| 2200 | self::$logger->debug('<<createUniqueIndex'); |
|
| 2201 | } |
|
| 2202 | ||
| 2203 | /** |
|
| 2204 | * (non-PHPdoc). |
|
| @@ 2145-2172 (lines=28) @@ | ||
| 2142 | * |
|
| 2143 | * @see Alpha\Model\ActiveRecordProviderInterface::createUniqueIndex() |
|
| 2144 | */ |
|
| 2145 | public function createUniqueIndex($attribute1Name, $attribute2Name = '', $attribute3Name = '') |
|
| 2146 | { |
|
| 2147 | self::$logger->debug('>>createUniqueIndex(attribute1Name=['.$attribute1Name.'], attribute2Name=['.$attribute2Name.'], attribute3Name=['.$attribute3Name.'])'); |
|
| 2148 | ||
| 2149 | if ($attribute2Name != '' && $attribute3Name != '') { |
|
| 2150 | $sqlQuery = 'CREATE UNIQUE INDEX IF NOT EXISTS '.$attribute1Name.'_'.$attribute2Name.'_'.$attribute3Name.'_unq_idx ON '.$this->BO->getTableName().' ('.$attribute1Name.','.$attribute2Name.','.$attribute3Name.');'; |
|
| 2151 | } |
|
| 2152 | ||
| 2153 | if ($attribute2Name != '' && $attribute3Name == '') { |
|
| 2154 | $sqlQuery = 'CREATE UNIQUE INDEX IF NOT EXISTS '.$attribute1Name.'_'.$attribute2Name.'_unq_idx ON '.$this->BO->getTableName().' ('.$attribute1Name.','.$attribute2Name.');'; |
|
| 2155 | } |
|
| 2156 | ||
| 2157 | if ($attribute2Name == '' && $attribute3Name == '') { |
|
| 2158 | $sqlQuery = 'CREATE UNIQUE INDEX IF NOT EXISTS '.$attribute1Name.'_unq_idx ON '.$this->BO->getTableName().' ('.$attribute1Name.');'; |
|
| 2159 | } |
|
| 2160 | ||
| 2161 | $this->BO->setLastQuery($sqlQuery); |
|
| 2162 | ||
| 2163 | $result = self::getConnection()->query($sqlQuery); |
|
| 2164 | ||
| 2165 | if ($result) { |
|
| 2166 | self::$logger->debug('Successfully created the unique index on ['.$this->BO->getTableName().']'); |
|
| 2167 | } else { |
|
| 2168 | throw new FailedIndexCreateException('Failed to create the unique index on ['.$this->BO->getTableName().'], error is ['.self::getConnection()->error.']'); |
|
| 2169 | } |
|
| 2170 | ||
| 2171 | self::$logger->debug('<<createUniqueIndex'); |
|
| 2172 | } |
|
| 2173 | ||
| 2174 | /** |
|
| 2175 | * (non-PHPdoc). |
|