/** * (non-PHPdoc). * * @see Alpha\Model\ActiveRecordProviderInterface::isTableOverloaded() */ public function isTableOverloaded() { self::$logger->debug('>>isTableOverloaded()'); $reflection = new ReflectionClass($this->BO); $classname = $reflection->getShortName(); $tablename = ucfirst($this->BO->getTableName()); // use reflection to check to see if we are dealing with a persistent type (e.g. DEnum) which are never overloaded $implementedInterfaces = $reflection->getInterfaces(); foreach ($implementedInterfaces as $interface) { if ($interface->name == 'Alpha\\Model\\Type\\TypeInterface') { self::$logger->debug('<<isTableOverloaded [false]'); return false; } } if ($classname != $tablename) { // loop over all BOs to see if there is one using the same table as this BO $BOclasses = ActiveRecord::getBOClassNames(); foreach ($BOclasses as $BOclassName) { $reflection = new ReflectionClass($BOclassName); $classname = $reflection->getShortName(); if ($tablename == $classname) { self::$logger->debug('<<isTableOverloaded [true]'); return true; } } throw new BadTableNameException('The table name [' . $tablename . '] for the class [' . $classname . '] is invalid as it does not match a BO definition in the system!'); self::$logger->debug('<<isTableOverloaded [false]'); return false; } else { // check to see if there is already a "classname" column in the database for this BO $query = 'SHOW COLUMNS FROM ' . $this->BO->getTableName(); $result = self::getConnection()->query($query); if ($result) { while ($row = $result->fetch_array(MYSQLI_ASSOC)) { if ('classname' == $row['Field']) { self::$logger->debug('<<isTableOverloaded [true]'); return true; } } } else { self::$logger->warn('Error during show columns [' . self::getConnection()->error . ']'); } self::$logger->debug('<<isTableOverloaded [false]'); return false; } }