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

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -