I'm studying cakephp with dot installation.
"Regarding ""View comment list"", it doesn't display correctly…
"
Is there a problem with the model or is it not displayed correctly in the view...
Please tell me who it is.
US>Dot Installation Video
http://dotinstall.com/lessons/basic_cakephp/7527
http://dotinstall.com/lessons/basic_cakephp/7528
[Comment.php]
<?php
class Comment extensions AppModel {
public$belongsTo='Post';
}
?>
[Post.php]
<?php
class Post extensions AppModel {
public$hasMany='Comment';
public$validate=array(
'title' = > array(
'rule' = > 'notEmpty',
'message' = > 'empty'
),
US>'body'=>array(
'rule' = > 'notEmpty'
)
);
}
?>
[view.ctp]
<h2><?phpechoh($post['Post']['title']);?>/h2>
<p><?phpechoh($post['Post']['body']);?>/p>
<h2>Comments<h2/>
<ul>
<?php foreach ($post['Comment'] as $comment): ?>
<li><?phpechoh($comment['body'])?>by<?phpechoh($comment['comment']);?></li>
<?php endforeach;?>
</ul>
I think there is a problem with the data in DB because the results are empty in SQL to retrieve comments.
The screenshot of the question appears to be an article with id=1
.
When entering data into the comments
table in the "#26 Comments table" of the series, the SQL code that matches post_id
as 7
by saying "If you look at the contents of the DB, let's make it 7."
As you can see in the video, post_id=7
data was entered, so I thought I couldn't get a comment. What do you think?
Association: Connecting Models—CakePHP Cookbook 2.x Documentation
The number of lines (Num.rows) in Query Nr.2 in the screenshot is 0, so there is no data in the comments table.
617 Uncaught (inpromise) Error on Electron: An object could not be cloned
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
578 Understanding How to Configure Google API Key
581 PHP ssh2_scp_send fails to send files as intended
912 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.