This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

Day 4 : two questions about save method in interest class

Discussion around this tutorial for symfony 1.0.x

Day 4 : two questions about save method in interest class

by luberti » Fri Sep 01, 2006 6:02 pm

First question:

for what I see the save method it is called each time you an object is saved to the db , i.e when is inserted and when is udpated.
I understand this from the fact that in the save method is called the save method of the question class that in this case update an existing question
If I'am right the counter interested_users will be update also each time the interest record is updated. That would be wrong obviously

Second question

The save method has the connection has a parameter and it is set to null. Why ?
I mean the con variabel is istantiated using

Propel::getConnection();

So it seems there is no need to pass it as a prameter and even I don't understand why it has to be set to null
luberti
Junior Member
 
Posts: 11
Joined: Wed Aug 30, 2006 3:17 pm

Re: Day 4 : two questions about save method in interest class

by luberti » Fri Sep 01, 2006 7:09 pm

I want to add another question that refer to the same funcionality.
In my case after the refactorin due to the introduction of the interested_users filed in the question table the number of interested users showed beside each question is alway 1.
However the database has been populated correctly.
I tried to show also the id of the question to which the field interested_users refers to. So I have changed the _interested_user.php to this:

<div class="interested_mark">

<?php echo count($question->getInterestedUsers()) ?>
<?php echo count($question->getId()) ?>
</div>


The number showed is always 1 for each question.
The listSuccess.php file contains what to me seems correct:

<?php use_helper('Text') ?>

<h1>popular questions</h1>

<?php foreach($questions as $question): ?>
<div class="question">
<div class="interested_block">

<?php include_partial('interested_user', array('question' => $question)) ?>

</div>


<h2><?php echo link_to($question->getTitle(), 'question/show?stripped_title='.$question->getStrippedTitle()) ?></h2>
<div class="question_body">

<?php echo truncate_text($question->getBody(), 200) ?>

</div>

</div>

<?php endforeach; ?>

<?php echo link_to ('create', 'question/create') ?>
luberti
Junior Member
 
Posts: 11
Joined: Wed Aug 30, 2006 3:17 pm

Re: Day 4 : two questions about save method in interest class

by baltha » Sat Jul 26, 2008 1:18 pm

<div class="interested_mark">

<?php echo count($question->getInterestedUsers()) ?>
<?php echo count($question->getId()) ?>
</div>

You should remove "count" when you are using the getInterstedUsers method. Your counters should be good, now.

Cheers
baltha
Junior Member
 
Posts: 1
Joined: Sat Jul 26, 2008 1:14 pm