Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Cdbexception: Missing Table In 2 Model Update

$
0
0
I keep getting the following everytime I try to create my first record in the User model.
CDbException

CDbCommand failed to execute the SQL statement: SQLSTATE[42S02]: Base table or view not found: 1146 Table 
'adxc.tbl_profile' doesn't exist. The SQL statement executed was: INSERT INTO `tbl_users` (`role`, `is_active`, 
`first_name`, `last_name`, `email`, `username`, `password_salt`, `password`, `date_created`) VALUES (:yp0, :yp1,
 :yp2, :yp3, :yp4, :yp5, :yp6, :yp7, :yp8)

'adxc.tbl_profile' indeed does not exsist, but in the Profile model:
	/**
	 * @return string the associated database table name
	 */
	public function tableName() {
		return '{{profiles}}';
	}

The UserController contains:
	/**
	 * Creates a new model.
	 * If creation is successful, the browser will be redirected to the 'view' page.
	 */
	public function actionCreate() {
		$userModel = new User;
		$profileModel = new Profile;

		// Uncomment the following line if AJAX validation is needed
		// $this->performAjaxValidation($model);

		if (isset($_POST['User'], $_POST['Profile'])) {
			// Populate the models with the inpute data
			$userModel->attributes = $_POST['User'];
			$profileModel->attributes = $_POST['Profile'];

			// You must validate BOTH prior to saving to get validation errors
			$isValid = $userModel->validate();
			$isValid = $profileModel->validate() && $isValid;

			//
			if ($isValid) {
				// Use the false parameter to disable re-validation on save()
				$userModel->save(false);
				$profileModel->user_id = $userModel->id;
				$profileModel->save(false);
				//Redirect to the 'view' page
				$this->redirect(array('user/view', 'id' => $userModel->id));
			} // EndIf ($isValid)
		} //EndIf (isset())


I'm at a loss. Can anyone point me in the right direction? Thanks.

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>