Beispiel #1
0
 function setTableName($table_name = null, $check_for_existence = AK_ACTIVE_RECORD_VALIDATE_TABLE_NAMES, $check_mode = false)
 {
     static $available_tables;
     if (empty($table_name)) {
         $table_name = AkInflector::tableize($this->getModelName());
     }
     if ($check_for_existence) {
         if (!isset($available_tables) || $check_mode) {
             if (!isset($this->_db)) {
                 $this->setConnection();
             }
             if (!AK_ACTIVE_RECORD_CACHE_DATABASE_SCHEMA || ($available_tables = AkDbSchemaCache::getAvailableTables()) === false) {
                 $available_tables = $this->_db->availableTables();
                 if (AK_ACTIVE_RECORD_CACHE_DATABASE_SCHEMA) {
                     AkDbSchemaCache::setAvailableTables($available_tables);
                 }
             }
         }
         if (!in_array($table_name, (array) $available_tables)) {
             if (!$check_mode) {
                 trigger_error(Ak::t('Unable to set "%table_name" table for the model "%model".' . '  There is no "%table_name" available into current database layout.' . ' Set AK_ACTIVE_RECORD_VALIDATE_TABLE_NAMES constant to false in order to' . ' avoid table name validation', array('%table_name' => $table_name, '%model' => $this->getModelName())), E_USER_WARNING);
             }
             return false;
         }
     }
     $this->_tableName = $table_name;
     return true;
 }