php - Function mysql in cakephp -
i'm trind query this:
$this->set('title', 'lista de posts'); $posts = $this->post->query("select id,titulo,data,hora,right(conteudo,200) conteudo,usuario posts;"); $this->set('posts', $posts); $this->layout = 'home';
but in view receive message:
notice (8): undefined index: post [app/view/posts/home.ctp, line 4]
but $posts = $this->post->find('all') works.
please can me use right(conteudo,200) in cake php?
thanks
forget 'query' method if you're new cake. special cases.
in postscontroller:
class postscontroller extends appcontroller { var $helpers = array('text'); public function index() { $posts = $this->paginate(); $this->set('posts', $posts); } }
in view:
foreach($posts $post) { echo $this->text->tail($post['post']['conteudo'], 200); }
Comments
Post a Comment