aguskianto Posted April 11, 2013 Share Posted April 11, 2013 Dear All, I've been following the book until I reach Chapter 5 Page 101: # protected/models/Page.phpprotected function beforeValidate(){ if(empty($this->user_id)) { $this->user_id = Yii::app()->user->id; } return parent::beforeValidate();} The problem that I found when I try to create Page: CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'user_id' at row 1. The SQL statement executed was: INSERT INTO `page` (`live`, `user_id`, `title`, `content`, `date_updated`, `date_published`) VALUES (:yp0, :yp1, :yp2, :yp3, NOW(), :yp4) Is there something that I miss? Regards, Agus Kianto Link to comment Share on other sites More sharing options...
aguskianto Posted April 11, 2013 Author Share Posted April 11, 2013 I think I found something interesting. I don't find Username Admin Password Admin on my User table. This username is used to accress create page. But this username is not listed on the table: 1 Test 2 Someones 3 Some Author 4 Another Author 5 Administrator 6 Another Admin 7 Jane 8 John 9 Curly 10 Moe 11 Larry 12 Vlad 13 testing 14 Latest Test 15 Joe Public 16 Jane Public Is there any connection between those two? Link to comment Share on other sites More sharing options...
Larry Posted April 12, 2013 Share Posted April 12, 2013 The default site generated uses "demo" and "admin" as possible usernames. In the book I also create database users (listed above). You'll need to decide which you're using. If you're using the latter, then you can log in using those values and you'll end up using that user ID when the page is created, thanks to the beforeValidate() method. Link to comment Share on other sites More sharing options...
aguskianto Posted April 15, 2013 Author Share Posted April 15, 2013 Well, I do understand that you create that user table. But, can I use that already in this chapter? Or, should I wait for later chapter for this things to work? One thing for sure, I try to login using those user in the user table but I got some: "Incorrect username or password" error. So, once again I ask: can this user in the table be used in this chapter already? or should I wait for another chapter. Link to comment Share on other sites More sharing options...
Larry Posted April 15, 2013 Share Posted April 15, 2013 The user table is not being used to login in Chapter 5. Link to comment Share on other sites More sharing options...
Recommended Posts