Feed items

I come back

Hi everybody!I have come back. I look - you read this blog and still have interest to CakePhp. So, I will write more and repost more interest and useful thing ;-)

Behavior in belongsTo request...

As usual I was not looking for easy ways, and as usual faces challenges not addressed in book.cakephp.org ;-) Always, the most troublesome part of the project for me is paginate and all that associated with it (sampling, sorting). And now, I once again stepped on a rake, and the answer to my question - no. So, what was the challenge: Model A - hasMany Model B Model B - belongsTo Model A Model B - actAs ( 'Image') Image - a wonderful Yevgenia Tomenko behavior, which is used to link entries in the model with the stored image. In the case of a request Model B -> ... of any form - behavior of hours worked, and I got me the correct information - in this case, pictures. However, when the problem began to build a query type Model B -> Model -> A (in terms of where the sample is on the fields of Model A)

double HABTM how to?

We have:Post HABTM TagPost HABTM CategoryWe need:Get all posts where Category.id = M, Tag.id = NIn CakePHP style, of couse ;-)Scaffolding (just use cake console, nothing strange, all - typical).Table:posts: id, title, bodytags: id, titlecategory: id,titlejoin tables:posts_tags: id, post_id, tag_idcategories_tags: id, post_id, category_idHow to?Easy...$this->Post->bindModel(array('hasOne' => array('PostsTag','CategoriesPost'))); (add param false if want to make paginate ;-)And now: $posts = $this->Post->find('all',array( 'fields' => 'Post.*', 'conditions' => array('PostsTag.tag_id' => 1,'CategoriesPost.category_id' => 4), ));That's all, folks.You can add params recursive = 0 (I think it good idea to reduce data in result)

Comments

Dear readers!Blogspot have too non-usability UI for comment reading and answering.Yes. I read all your comments, but I remember - I saw some questions in your comments, but after "aprove" I cann't found comments ;-(If you have question - ask me in twitter: cakephphttp://twitter.com/cakephpI'll try answer to all your question with my bad english ;-)

CakePHP 1.2 Stable is finally released!

And now we have release ;-)Merry Christmas and happy New Year and happy CakePHP! ;-)

ACO\ARO - no problem!

Recently, I finished my first application using Auth (ACO \ ARO). It turned out it was not scared. It's simple, easy. However, there are nuances. First hand accounts add all of these controllers ACO / ARO. Secondly Auth after login does not want to understand the prefix admin, and I get to the admin / posts / main - no way out, only to / posts / main. I had to write an additional line in routes.php In general - I am happy. Very nice work. Faster and more convenient than dispose of around $ this-> obAuth-> check (...) ;-)

CakePHP vs RoR

Why you still with CakePHP? Why don't switch onto Ruby on Rails?Just interesting to know...

ACL ACO Howto...

Just do it few simple steps, and you haven't any more questions about ACL|ARO...http://book.cakephp.org/view/641/Simple-Acl-controlled-Application

CakeBook source

And now You can read and study on CakeBook (book.cakeforge.org) sources code ;-)http://thechaw.com/cakebookI'm going for popcorn ;-)You see? Guys work on CakeBook over 39 years! Starting in 1969... Nice hippy time.. Love drugs and rock'n'roll ;-)So it's funny, but really - very nice time to start learning how to write code RIGHT

PHP 2008

Asked to look and move the site, written by one system administrator. The site is written in php without a bare framework. What do you say friends? At the yard - in 2008, and within - solid global variables. And type: INSERT INTO ... ". $ _GET [" Param1 "] - and does, at every turn. As their site is not hacked so far - do not understand