Hi, cakePHPers:
I am an architect, not quite familiar with CakePHP before, recently after an upgrade to CakePHP 2.4.6, $post['Post']['id'] not works now, but $post[0]['id'] is ok.
I am not sure it's caused by CakePHP or other stacks, because I upgraded CakePHP from 2.1 to 2.4.6 , CentOS from 6.0 to 6.5, and PHP upgraded from 5.2.14 to 5.5.10 too.
Here's the code and screenshot:
Model/Post.php
<?php
class Post extends AppModel {
}
Posts/view.ctp:
<h1><?php echo h($post['Post']['title']); ?></h1>
<p><small>Created: <?php echo $post['Post']['created']; ?></small></p>
<p><?php echo $post['Post']['body']; ?></p>
<h1><?php echo h($post[0]['title']); ?></h1>
<p><small>Created: <?php echo $post[0]['created']; ?></small></p>
<p><?php echo $post[0]['body']; ?></p>
PostsController.php:
<?php class PostsController extends AppController {
public $helpers = array('Html', 'Form');
public function view($id = null ) {
$post = $this->Post->findById($id);
print_r($post);
$this->set('post', $post);
}
}
Please let me know what's wrong, the code? the upgrade of CakePHP, or other stack issue. Thanks.
-- I am an architect, not quite familiar with CakePHP before, recently after an upgrade to CakePHP 2.4.6, $post['Post']['id'] not works now, but $post[0]['id'] is ok.
I am not sure it's caused by CakePHP or other stacks, because I upgraded CakePHP from 2.1 to 2.4.6 , CentOS from 6.0 to 6.5, and PHP upgraded from 5.2.14 to 5.5.10 too.
Here's the code and screenshot:
Model/Post.php
<?php
class Post extends AppModel {
}
Posts/view.ctp:
<h1><?php echo h($post['Post']['title']); ?></h1>
<p><small>Created: <?php echo $post['Post']['created']; ?></small></p>
<p><?php echo $post['Post']['body']; ?></p>
<h1><?php echo h($post[0]['title']); ?></h1>
<p><small>Created: <?php echo $post[0]['created']; ?></small></p>
<p><?php echo $post[0]['body']; ?></p>
PostsController.php:
<?php class PostsController extends AppController {
public $helpers = array('Html', 'Form');
public function view($id = null ) {
$post = $this->Post->findById($id);
print_r($post);
$this->set('post', $post);
}
}
Please let me know what's wrong, the code? the upgrade of CakePHP, or other stack issue. Thanks.
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment