tags:

views:

100

answers:

1

Background I am developing my blog application in Cake PHP. I aim to provide an intro text for each post on the home page. The user can then click on the "Read more" link to read the entire post. Following is my posts table.

 $query = 'CREATE TABLE posts (
           id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
        name VARCHAR(255) DEFAULT NULL,
        date DATETIME DEFAULT NULL,
        summary TEXT,
        content TEXT,
        user_id INT(11) DEFAULT NULL,
        PRIMARY KEY(id))
        ENGINE=MyISAM';

Following is the index.ctp file

<?php foreach($posts as $post): ?>
<div class="story">
    <?php echo $html->link('<h1>'.$post['Post']['name'].'</h1>', '/posts/view/'.$post['Post']['id'],null,null,false); ?>
    <p>Posted  <?php echo date('M jS Y, g:i a', strtotime($post['Post']['date'])); ?> </p>
    <p><b>By:  <?php echo $post['User']['firstname']; ?>  <?php echo $post['User']['lastname']; ?></b></p>
    <br/>
    <p><?php echo $post['Post']['summary']; ?><?php echo $html->link('<h2>Read More</h2>', '/posts/view/'.$post['Post']['id'],null,null,false); ?></p>
</div>
<?php endforeach; ?>

Similarly,I have also added the summary field in add.ctp, edit.ctp and view.ctp

Problem Now the problem is that when I try to create a new post, the summary field is not getting committed to the database. There is no problem with other fields. Moreover, even when I manually add text into the summary field from phpMyAdmin, I still can't view it in my home page. No errors have been reported. What am I missing??

+2  A: 

Did you already have a version of the "posts" table that didn't have a "summary" field, then went back and added it? If so, you may need to delete your model cache.

rm -rf app/tmp/cache/models/cake_model_*
Matt Huggins
ya...that is what I did...can you please elaborate on this point?or if you have some link providing more information??
Learner
hey..thanks a ton...i figured it out....i was just about to tear my hairs apart ;)
Learner
Glad you figured it out. Was this the trick that solved your problem? If not, mind sharing what you did for others who come across this post with the same issue as you? :)
Matt Huggins
I did what you suggested...just deleted the cache files from app\tmp\cache\models directory and it worked :)
Learner