Re: Table join confusion...

2009-11-07 Thread Thiago Nuic Vidigal
You can include other tables in the query using the 'joins' option of the
Model->find method.


On Sat, Nov 7, 2009 at 4:48 PM, jakobjp  wrote:

>
> I need a little assistance with a join over 3 tables.
>
> I have the following Models (User > Profile > Infogroup >
> Information):
> - User (hasMany Profile)
> - Profile (belongsTo User, hasMany Infogroup)
> - Infogroup (belongsTo Profile, hasMany Information)
> - Information (belongsTo Infogroup)
>
> The relationships are defined in the model classes, and there is no
> problem getting the associated data, when for example fetching a User.
>
> However, what do I need to do to get all Information that belongs to a
> specific User?
>
> I.e. all rows from the informations table "where
> Information.infogroup_id = Infogroup_id AND Infogroup.profile_id =
> Profile.id AND Profile.user_id = XYZ"?
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: $model->find("list") and concatenated fields

2009-09-17 Thread Thiago Nuic Vidigal
teknoid has a post on his blog about a "superlist" that does what you want.



On Wed, Sep 16, 2009 at 11:14 AM, santino83  wrote:

>
> Hi,
>
> First of all you should use find('first') to get a list from your
> model. As you can read in http://book.cakephp.org/view/810/find-list,
> you could set $displayField in Model and tell to cake which field it
> should use as "description". In your case, it seems cake couldn't
> concatenate fields as description, so a solution could be
>
> 1) ovveride find in Model class
> 2) using a custom function
>
> In both cases, your function will retry all model records, and then
> create a list using some utilities. I use this:
>
> $results = $this->find('all', array( 'conditions' => ..., .. .. ) );
>
> /*
> * Extract list, result: model_id => code+description
>  */
> return $results ? array_combine(Set::extract('/MODELNAME/id',
> $results), array_map(array($this,'getDescription'),$results) ) :
> null;
>
> and getDescription:
>
> private function getDescription($data){
>  return $data['MODELNAME']['code'].' '.$data['MODELNAME']
> ['description'];
> }
>
> note: change MODELNAME rightly
>
>
> On Sep 16, 3:51 pm, Ernesto  wrote:
> > Hello.
> >
> > i have a model that's using a simple 3-columns table
> >
> > item_id
> > code
> > description
> >
> > i want to obtain a select box that shows the fields "code" and
> > "description" concatenated.
> >
> > right now i'm using a foreach loop
> >
> > foreach ($items as $key => $item) $selectArray[$key] = $item["code"] .
> > " - " . $item["description"];
> >
> > is there any way to do this directly in the "find" call?
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: PHP IDEs

2009-09-09 Thread Thiago Nuic Vidigal
I like netbeans a lot. It shows documentation from PHP functions inline in
the editor, which is very useful.


On Wed, Sep 9, 2009 at 12:18 PM, Bob Albert  wrote:

>
> I've been doing my PHP coding in BBedit on the Mac, but thinking that
> it would be better if I started to use an IDE for PHP. Can anyone
> recommend a good free or low cost one that works well on Mac and with
> CakePHP framework? I've briefly looked at Zend Studio but it's too
> expensive for me right now and looks to be geared toward Zend framework.
>
> Thanks,
> Bob
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Chain media view

2009-09-08 Thread Thiago Nuic Vidigal
Got it working by creating my own Media view based on CakePHP's one.


On Tue, Sep 8, 2009 at 11:43 AM, Thiago Nuic Vidigal wrote:

> Hi,
>
> I'm trying to make a chain media view in order to integrate my system with
> another one. One of the issues I'm having is showing images. Since the
> system that holds the images is using media view to protect the images I was
> wondering if it is possible to chain the response from the media view of one
> system to media view to another. One lazy approach would be to pass the
> session_id as a GET parameter, but that would not be very nice. In java I
> would use a chain of streams. Anyone had this problem?
>
> Thank in advance.
> Thiago Nuic Vidigal
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Chain media view

2009-09-08 Thread Thiago Nuic Vidigal
Hi,

I'm trying to make a chain media view in order to integrate my system with
another one. One of the issues I'm having is showing images. Since the
system that holds the images is using media view to protect the images I was
wondering if it is possible to chain the response from the media view of one
system to media view to another. One lazy approach would be to pass the
session_id as a GET parameter, but that would not be very nice. In java I
would use a chain of streams. Anyone had this problem?

Thank in advance.
Thiago Nuic Vidigal

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: how to load initial data?

2009-09-02 Thread Thiago Nuic Vidigal
you can create a custom shell to do it...

On Wed, Sep 2, 2009 at 4:21 PM, Miles J  wrote:

>
> Cake doesnt import x amount of rows into your database. I ran into the
> same problem months ago, I had to write my own scripts to populate
> with test data.
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Using Cake models from non-cake project

2009-08-29 Thread Thiago Nuic Vidigal
I dont know if it will do what you want, but you can create your own cake
shell as described i the book...


On Sat, Aug 29, 2009 at 1:25 PM, tbirand  wrote:

>
> Hello all,
>
> I've just started working with CakePHP a few days ago, and I really
> like it. I develop Ruby on Rails apps as well, but having a similar
> approach under PHP is most welcome since most of my clients have PHP
> enabled hosts and I'm a bit more familiar with the language.
>
> That being said, I've a question that I couldn't find an answer to so
> far; is there any way to use the models in my cake application from an
> outside non-cake php script? This is possible with Rails, I'm sure it
> can be done here as well but after searching for a few hours I thought
> I'd post here. Anyone have an idea? (I've already tried the technique
> describet at
> http://debuggable.com/posts/the-ultimate-cakephp-bootstrap-technique:480f4dd5-2bcc-40cb-b45f-4b1dcbdd56cb
> to no avail.) I need to do this so I can use some newer db tables and
> their respective models in a legacy php application until I have the
> time to completely rewrite it.
>
> Thanks in advance,
>
> T.J.
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---