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 ;-)
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)
turned out - that the search and pedzhinatsiya work perfectly, but the results of Model B - no trace of the behavior ... I just got a field model, without the right to me «curvature».
No dancing, dancing with Contain, the order request, etc. - No effect. Well the answer is no, and guglegruppe.
And today I found another rake, but with behavior Translate. If you use the instructions and do as they advised - and it works fine, except my favorite pedzhinatsii ...
And it is - sort of fields located in the i18n table - you can not. Not possible. Only those fields that are present in an explicit form. Whew.
Of course, I do not want to say that sorting through the i18n table built to work quickly, or, in principle, be attributable to work. Maybe not. But in this case, if you need some sort of results except for id, created - no chance to use the behavior you do not. It does not work. : (
And if the rake can bypass the second request (first received the list of id Model B, and then to obtain directly from the Model B, all records (this is work behavior). In the second rake, the only way to sort - to dispense with boxed behavior.
But I have the trick ;-)
$results = this->Immovable->Best->find('all',array('conditions' => array('Best.country_id' => $country), 'limit' => 5, 'contain' => array('Immovable' => array('order' => array('Immovable.created' => 'ASC')))));
$result = $this->Immovable->Behaviors->Image->afterFind($this->Immovable, $results, false);
In this case, the results will be applied behavior
Cheers!
We have:
Post HABTM Tag
Post HABTM Category
We need:
Get all posts where Category.id = M, Tag.id = N
In CakePHP style, of couse ;-)
Scaffolding (just use cake console, nothing strange, all - typical).
Table:
posts: id, title, body
tags: id, title
category: id,title
join tables:
posts_tags: id, post_id, tag_id
categories_tags: id, post_id, category_id
How 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)
You can use any cake-style 'or', 'and' in conditions query.
And this works well ;-)
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: cakephp
http://twitter.com/cakephp
I'll try answer to all your question with my bad english ;-)
And now we have release ;-)
Merry Christmas and happy New Year and happy CakePHP! ;-)
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 (...)
;-)
Why you still with CakePHP? Why don't switch onto Ruby on Rails?
Just interesting to know...
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
And now You can read and study on CakeBook (book.cakeforge.org) sources code ;-)
http://thechaw.com/cakebook
I'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
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
Hi, friends!
I was silent a long time, because it was a lot of work. Yes, despite the looming default in our country (I hope I am wrong). Like most of my friends, we work, work, work ...
Now I want you to submit a site devoted to selling cars - prodam-auto.com. The site in Russian, so forgive me, the English-speaking friends (google will help you to understand that where and how).
The site just completed its local run and fixing errors. Now going on alpha testing.
I have already found a couple of points that I missed in the development of the site. Now I think whether it is a mistake, or feature ;-)
Thanks to that tolerate me!
I think the twitter is more useful than short message in blogger.com
So, welcome to my twit: www.twitter.com/cakephp ;-)
I went to see w3school statistics browsers… However, employment trend emerges.
As this is still statistics, that is close to the "Rules on Water" does not look at absolute figures, but on the relative changes…
2004, IE = 76.2%
2005, IE = 68.9% Fx 23.6%
In 2006 IE = 60.6% Fx 29.9%
In 2007 IE = 57% Fx 36.3%
2008, IE = 50.6% Fx 43.7%
Even if there plus minus 5-10% in accuracy. The trend, nevertheless, to the person. And yet here, I think Google Chrome will make serious amendments to the statistics.
According to statistics LiveInternet for September 1-7 at GC 0.6%, for 8-14 September (but today only 9 - e!) - 0.8%
Less percent, is, of course drop in the ocean. But this is not two weeks have passed since the advent of the browser. All the more useful feature such as - creating web application - again, this is NOT FireFox from "unclear whom", and the great Google (! That for companies and offices important), fast (as promised) processing Javascript that in my opinion it is not important, but arhivazhno, Google Chrome opportunity to establish normal user under Windows without resorting to the services administrator (not personally experimented, but overhear in podcasts).
IE as I see it, CMS for the site can be targeted at Google Chrome (almost Safari), a company with more likely to agree to set Chrome (FF on - the refusal of nearly 100% - I do not know why). And fast work with JS - also can not fail to please users jquery / prototype and (especially) extjs.
Honestly admit, I personally Google Chrome has not yet watched. Wait a formal assembly under poppy (Google shame!)
Customer: Hello. I am here for you e-mail sent, with a list of sites which I like. Look.
Me: (I looked). Why do you sent me html? Why could not link?
Customer: What is the difference?
Me: There are. Okay. (Open html-file search for a direct link to the site. Open site)
Customer: I decided that I did not write it like that do not like. I better explain in words. So will be faster.
Me: Do you think that I remember it all?
Customer: Are you inscribe.
Me: 8-O (curtain)
Recently I met to do a careful study yahoo pipes, as it turned out - something is broken, and pipes.yahoo do not work. Everywhere error 503.
Even previously saved to open pipes is not possible. Judging by reports on the forum - a problem with the 7-8 morning.
And I just encountered a problem that String.Translate module converts any field except the field content: encoded. And I just met to find out what the problem is - 503 :(
Well then. Let's wait. Meanwhile, loans something more useful. For example CakePHP :)
Strange error in the helpers who is responsible for form:
echo $ form-> dateTime ( "Showtime", "DMY", 24, null, array ( "minYear" => 2008, "maxYear" => 2012, 'monthNames' => false, "interval" => 15) false);
All right? Everything!
However, in html see the following code:
< name="data[Showtime][Showtime][day]" id="ShowtimeShowtimeDay">
< value="01"> 1
...
< / select> -
< name="data[Showtime][month]" id="ShowtimeMonth">
< value="01"> 01
Why do we have chosen day encoded twice Showtime? Other parameters are coded properly. If only not forget that in order to set the interval mode 24 hours a day, should be a bit sub-source code (ticket already established).
We are talking about CakePHP 1.2 RC2
If you are new user of CakePHP, forget about CakePHP 1.1 (stable). Learn CakePHP 1.2.
As you know, I'm a happy owner a Apple Macbook. Also, for home mobile development ;-) I get Zyxel 660HTW2EE (ADSL modem + router + WiFi).
At present moment a have a lot of free time for self improvement and I can learn CakePHP deeper and deeper, as it possible ;-)
YESS! I did it! ;-)
It's very strange, but I cann't use this cake baker under MacOS ;-(
After my switching into MacOS I'm start to use cakephp.dmg with latest version of this wonderful framework. But I found some troubles with use this image (dmg).
My pal (pal by ICQ ;-) broken mind about simple problem...