« first day  last day (14 days later) » 

7:29 AM
Hello!
 
lin
hey there
so first of all, where are you from? ;)
 
I am from india
you?
 
lin
Germany. You are welcome.
So, as far as i can see, you are pretty new to ORM/MVC pattern and all the goodness in it, right?
 
Ok
Yes
 
lin
Iam a bit afraid, that we solved 3 problems and the main question is not what we talk about now.
but its oke
So this is your last Post "$comment->post_id=$this->id; is already there in the addComment() of post model. I tried putting CVarDumper::dump($this->id); Yii::app()->end(); above it, but it doesn't show anything. I figure I messed up writing the code somewhere, will go over the basics again and try copy pasting the code from tutorial. Also I am able to chat now! "
 
7:41 AM
yep
I am planning to redo the whole thing, because I might have made some errors while typing
 
lin
you are sure, $this->id exist in DB while doing "$comment->post_id = $this->id" ?
 
yes
 
lin
Ok, did you changed your GII Generated models yourself?
 
yes
 
lin
;) ...
 
7:44 AM
you can see the current code here if you like, github.com/arcticf0x/YiiBlog/tree/master/protected
 
lin
If your ORM is "good". Try to re-generate all your models. Right after that .. your "comment->save()" should work.
ah cool thanks.
 
would that reset the modifications made?
 
lin
hehe, your codes look realy "indian"-style :D
 
really? how?
 
lin
yes, but you need to generate them anytime you change your ORM. You need to copy past function like "approve" (which you wrote), by yourself.

Code style guide: http://framework.zend.com/manual/1.12/en/coding-standard.coding-style.html
 
7:48 AM
should I remove the default values I had added on post_id and status in tbl_comment?
 
lin
in your ORM?
/DB
 
yes in DB
DB and ORM is the same thing right?
 
lin
na, not really. but in this case .. yes. ;) ORM is your Persistence Model, which can be a "DB" or any other persitence you like to save your data to. There are also ORMs based on files, etc.
but lets focus your main problem.
did you change relation in "POST" Model?
/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(

'author' => array(self::BELONGS_TO, 'User', 'author_id'),

'comments' => array(self::HAS_MANY, 'Comment', 'post_id',
'condition'=>'comments.status='.Comment::STATUS_APPROVED,
'order'=>'comments.create_time DESC'),

'commentCount'=> array(self::STAT, 'Comment', 'post_id',
'condition'=>'status='.Comment::STATUS_APPROVED),
 
Yes
 
lin
okey, you are using git, thats pretty good. Maybe you try to cleanup your models again generating by GII and try make it work without your own relations and depencies.
if that works fine, build up on them.
 
7:52 AM
just a minute, I will regenerate all the models again.
 
lin
Just try, i stay here, the hole day ;)
 
ok, thanks
 
lin
Little hint: in your "Tag.php" model is a function:

public static function string2array($tags)
{
return preg_split('/\s*,\s*/',trim($tags),-1,PREG_SPLIT_NO_EMPTY);
}

It doesnt do anything with the model "$this", this function is an helper needs to be outsourced into https://github.com/arcticf0x/YiiBlog/tree/master/protected/components/

Write a Helper.php class and put that into ;)
Models doesnt hold any functions which does not handle any model data ;)
 
Ok, but I was following all this from this tutorial, yiiframework.com/doc/blog/1.1/en/prototype.scaffold
and now recreating the models has broken everything
only the index loads fine
 
lin
what does the error reporting say? ;)
any PHP errors?
Yes i know this tutorial, and string2array is absolutly wrong placed ;)
 
8:02 AM
Ok
Fatal error: Undefined class constant 'STATUS_PUBLISHED' in /usr/share/nginx/html/blog/protected/controllers/PostController.php on line 138
I am copying all the model code from the demo blog
and now this,
The table "{{post}}" for active record class "Post" cannot be found in the database.
Do I need to do the CRUD for post and comment again aswell?
 
lin
yes
const STATUS_DRAFT=1;
const STATUS_PUBLISHED=2;
const STATUS_ARCHIVED=3;
add this constants, like the blog tutorial said.
and .. I dont know why your "Post" is missing in DB. Check your database ;) ?
Do you know GII? ;) Or why did your copied the models?
 
I first created the models using GII
then copied the "new" code from blog example already provided
I want to start fresh, its a mess to debug this one
 
lin
yes, you should start from begin.
its to tricky so solve this. :(
 
yep
 
lin
btw. i did the tutorial 2 times to ;) .. but this is some years ago :P
but right after that, ive been fine with yii.
 
8:13 AM
glad to hear that!
 
lin
Yii is pretty good, maybe you start with Yii2 right now...
cause .. it makes a lot of sence.
 
isnt it still in beta?
 
lin
8:58 AM
yes, but nearly in RC
 
but getting, [InvalidArgumentException]
Could not find package yiisoft/yii2-app-basic with stability stable.
 
9:17 AM
Ok, I installed yii2
Its so different from 1.1, It creates a sample application straight away
 
lin
10:10 AM
hoi
i check this soon
Check this soon
 
lin
10:31 AM
hi ?
"Its so different from 1.1, It creates a sample application straight away" -> yes but its the future. Yii will be outdated soon :)
 
 
2 hours later…
12:07 PM
Why is the new automatically generated relation method is like this?
'tblComments' => array(self::HAS_MANY, 'TblComment', 'post_id'),
while the tutorial says,
'comments' => array(self::HAS_MANY, 'Comment', 'post_id',
 

« first day  last day (14 days later) »