ModelCode::validateTableName PHP Method

validateTableName() public method

public validateTableName ( $attribute, $params )
    public function validateTableName($attribute, $params)
    {
        if ($this->tableName != '' && $this->tableName[strlen($this->tableName) - 1] === '*') {
            $this->modelClass = '';
        } else {
            if ($this->getTableSchema($this->tableName) === null) {
                $this->addError('tableName', "Table '{$this->tableName}' does not exist.");
            }
            if ($this->modelClass === '') {
                $this->addError('modelClass', 'Model Class cannot be blank.');
            }
        }
    }

Usage Example

 /**
  * Validate the tableName
  * ModelCode does not want to create a class with an invalid name, however it does not
  * take into account the modelPrefix, so we have to prefix the keywords before checking
  * @param $attribute
  * @param $params
  */
 public function validateTableName($attribute, $params)
 {
     if ($this->modelPrefix) {
         $keywords = self::$keywords;
         self::$keywords = array();
         foreach ($keywords as $keyword) {
             self::$keywords[] = $this->modelPrefix . $keyword;
         }
         parent::validateTableName($attribute, $params);
         self::$keywords = $keywords;
     } else {
         parent::validateTableName($attribute, $params);
     }
 }