| @@ 2012-2048 (lines=37) @@ | ||
| 2009 | $indexNames = $this->getIndexes(); |
|
| 2010 | ||
| 2011 | // process unique keys |
|
| 2012 | foreach ($this->BO->getUniqueAttributes() as $prop) { |
|
| 2013 | // check for composite indexes |
|
| 2014 | if (mb_strpos($prop, '+')) { |
|
| 2015 | $attributes = explode('+', $prop); |
|
| 2016 | ||
| 2017 | $index_exists = false; |
|
| 2018 | foreach ($indexNames as $index) { |
|
| 2019 | if ($attributes[0].'_'.$attributes[1].'_unq_idx' == $index) { |
|
| 2020 | $index_exists = true; |
|
| 2021 | } |
|
| 2022 | if (count($attributes) == 3) { |
|
| 2023 | if ($attributes[0].'_'.$attributes[1].'_'.$attributes[2].'_unq_idx' == $index) { |
|
| 2024 | $index_exists = true; |
|
| 2025 | } |
|
| 2026 | } |
|
| 2027 | } |
|
| 2028 | ||
| 2029 | if (!$index_exists) { |
|
| 2030 | if (count($attributes) == 3) { |
|
| 2031 | $this->BO->createUniqueIndex($attributes[0], $attributes[1], $attributes[2]); |
|
| 2032 | } else { |
|
| 2033 | $this->BO->createUniqueIndex($attributes[0], $attributes[1]); |
|
| 2034 | } |
|
| 2035 | } |
|
| 2036 | } else { |
|
| 2037 | $index_exists = false; |
|
| 2038 | foreach ($indexNames as $index) { |
|
| 2039 | if ($prop.'_unq_idx' == $index) { |
|
| 2040 | $index_exists = true; |
|
| 2041 | } |
|
| 2042 | } |
|
| 2043 | ||
| 2044 | if (!$index_exists) { |
|
| 2045 | $this->createUniqueIndex($prop); |
|
| 2046 | } |
|
| 2047 | } |
|
| 2048 | } |
|
| 2049 | ||
| 2050 | // process foreign-key indexes |
|
| 2051 | // get the class attributes |
|
| @@ 1993-2029 (lines=37) @@ | ||
| 1990 | $indexNames = $this->BO->getIndexes(); |
|
| 1991 | ||
| 1992 | // process unique keys |
|
| 1993 | foreach ($this->BO->getUniqueAttributes() as $prop) { |
|
| 1994 | // check for composite indexes |
|
| 1995 | if (mb_strpos($prop, '+')) { |
|
| 1996 | $attributes = explode('+', $prop); |
|
| 1997 | ||
| 1998 | $index_exists = false; |
|
| 1999 | foreach ($indexNames as $index) { |
|
| 2000 | if ($attributes[0].'_'.$attributes[1].'_unq_idx' == $index) { |
|
| 2001 | $index_exists = true; |
|
| 2002 | } |
|
| 2003 | if (count($attributes) == 3) { |
|
| 2004 | if ($attributes[0].'_'.$attributes[1].'_'.$attributes[2].'_unq_idx' == $index) { |
|
| 2005 | $index_exists = true; |
|
| 2006 | } |
|
| 2007 | } |
|
| 2008 | } |
|
| 2009 | ||
| 2010 | if (!$index_exists) { |
|
| 2011 | if (count($attributes) == 3) { |
|
| 2012 | $this->BO->createUniqueIndex($attributes[0], $attributes[1], $attributes[2]); |
|
| 2013 | } else { |
|
| 2014 | $this->BO->createUniqueIndex($attributes[0], $attributes[1]); |
|
| 2015 | } |
|
| 2016 | } |
|
| 2017 | } else { |
|
| 2018 | $index_exists = false; |
|
| 2019 | foreach ($indexNames as $index) { |
|
| 2020 | if ($prop.'_unq_idx' == $index) { |
|
| 2021 | $index_exists = true; |
|
| 2022 | } |
|
| 2023 | } |
|
| 2024 | ||
| 2025 | if (!$index_exists) { |
|
| 2026 | $this->createUniqueIndex($prop); |
|
| 2027 | } |
|
| 2028 | } |
|
| 2029 | } |
|
| 2030 | ||
| 2031 | self::$logger->debug('<<checkIndexes'); |
|
| 2032 | } |
|