Re: setting up URL

2006-11-19 Thread Eric C Blount
Did you move the index.php file from development.example.com/index.php and
the .htaccess file? I had problems when the .htaccess file didn't get moved
over.

HTH,
Eric


On 11/19/06, leamas <[EMAIL PROTECTED]> wrote:
>
>
> I have searched for an answer, but because I really don't know what to
> search I didn't find an answer.
>
> What I need is for my url to look like this:
>
> www.example.com/products/action
> however, what I'm getting now is:
> www.example.com/app/products/action
>
> What I don't get is when I first started, I installed it into a
> development folder and it worked.  The URL looked like
> development.example.com/products/action
>
> How come in the development URL it doesn't show 'app' but if I want it
> on my root it does?
>
>
> >
>


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


Custom HABTM SQL query

2006-11-19 Thread Jon Bennett

Hi,

In my app I have 3 2 tables:

Clients
Animations

Clients and Animations are linked via a HABTM association. Slightly
unusually, a client needs to have access to all animations that
haven't been linked to any client (other than themselves).

So far I'm doing:

$this->Animation->execute ("SELECT DISTINCT animations.* from
animations, animations_clients WHERE (animations.id <>
animations_clients.animation_id OR animations_clients.client_id =
'{$this->client_id}') ORDER BY animations.name");

This seems to be getting all records still, even though some are
definitely associated to a client other than the active logged in
client.

Any pointers as to how I can accomplish this.

Thanks,

Jon


-- 


jon bennett
t: +44 (0) 1225 341 039 w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett

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



Re: hasMany query question

2006-11-19 Thread Nathan Garza
Thanks for the reply.  Let me expand abit.  Model 'A' hasMany 'B' and
hasMany 'C'.  I want to find the instance of model 'A' that has a spicific
'B' AND a specific 'C'.  Now here's the part I left out.  Model 'D' hasMany
'B' and 'E' hasMany 'C'.  So, a given 'B' or 'C' belongs to only one 'A',
but also to only  one 'D' or 'E' (as apposed to many  'A', 'D' & 'E's).
Basically, 'A' hasAndBelongsTo 'D' and 'E', but the join tables are too
complex for cake's standard habt relationship to work (there's more in there
than I've described).  So I created a model for the join tables and made the
change in the relationships.

So, one 'Ad' can have many 'Classifications', and many 'Locations', but I'm
looking for the specific 'Ad' that has a 'Classification' AND a 'Location'
containing the correct 'Category' and 'City' respectively.

However, the question remains, is it posible to use a feild from a table
associated with a hasMany relationship in the findAll($conditions) array?

What I've recently decided to try on monday is to do:
$var1 = $this->Ad->Location->findAll($conditions);
$var2 = $this->Ad->Classification->findAll($conditions);
$ads = array_intersect($var1, $var2);

Although that seems like a weird way to do it.  Then again, maybe my whole
concept is the weird way to do it in the first place.
--
ng

On 11/19/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
> Hmmm... Me thinks you have a logic problem.
>
> If "Classification belongsTo Ad " and "Location belongsTo Ad" then
> searching by both Location.id and Classification.id at the same time is
> redundant, since they would both share (at most) exactly one parent.
>
> So if "Classification belongsTo Ad ", then Classification has only one
> parent, and you can simply do this:
> $this->Ad->Classifications->recursive = 3;
> $data =
> $this->Ad->Classifications->findById($this->data['Classification']['id']);
> $ad = $data['Ad'];
>
> Or if "Location belongsTo Ad ", then Location has only one parent, and
> you can simply do this:
> $this->Ad->Location->recursive = 3;
> $data = $this->Ad->Location->findById($this->data['Location']['id']);
> $ad = $data['Ad'];
>
> Back to the logic problem... If one ad can have more than one
> classification, and many adds can share the same classification, then
> you are not using the correct relationships.  Based on your question, I
> suspect you should be using hasAndBelongsToMany. If you think this is
> possible, read the model chapter of the cake manual again:
> http://manual.cakephp.org/chapter/models   Otherwise, ignore my
> response.
>
> sc
>
>
> On Nov 19, 12:18 am, "naryga" <[EMAIL PROTECTED]> wrote:
> > Ok, I have 3 models:
> > Ad, Classification, Location
> > Ad hasMany Classification,Location
> > Location belongsTo Ad
> > Classification belongsTo Ad
> > I want to be able to search for Ads based on the associated
> > Classifications and Locations.  I've tried using something like:
> > 
> >  $this->Ad->findAll("Classification.id =
> > {$this->data['Classification']['id']} AND Location.id =
> > {$this->data['Location']['id']}");
> > 
> > But this results in: "SQL Error in model Post: 1054: Unknown column
> > 'Classification.id' in 'where clause'"
> > Using Debug: 3, I found that the problem seems to be that when
> > searching on a model with hasMany associations, an SQL alias is not
> > created for the associated modles (ie, Classification as
> > classifications).  However, changing my where statment to
> > classifications.id = ... Doesn't seem to help.
> >
> > If I only wanted to use one of the associated models to limit the
> > results, I would use
> > $this->Ad->Classifications->findAll("Classification.id =
> > {$this->data['Classification']['id']}); which works just fine.   Is
> > there some other way I should be doing this?  Thanks in advance!
>
>
> >
>


-- 

Nathan Garza

AshLeaf Media | Director of Technology Innovations
_
www.ashleafmedia.com | [EMAIL PROTECTED] | 832.514.5726


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


Re: simple cakePHP question

2006-11-19 Thread [EMAIL PROTECTED]

> i've been looking at the API but I just don't see how I call
> _deleteHasMany? I do not want to cascade delete to child associations
> if I delete the master (in this case User). I want to delete ALL the
> rows on the many side of the relationship (in my case 'preferences')
> but the "one" side (the User) is not to be deleted.

_deleteHasMany method will not delete the User, just the child
(profile) records.
$this->User->_deleteHasMany($user_id, true);

However, if you have other "HasMany" associations, then they too will
also be deleted.

If that doesn't work for you... there's nothing wrong with doing it the
easy way:
$this->Preference->execute("DELETE FROM preferences WHERE user.id =" .
$user_id);


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



How to setup a fitting folder-/url-structure

2006-11-19 Thread Axel Wuestemann

Hi,

for a cms I need a url-structure like this

frontend:
www.mysite.de/pages/0815
that is simply done with /app/pages_controller.php

backend:
I would have core functionality as app/sitechips (the name of the cms)
an exendable contentypes as plugins:
/app/plugins/articles/controllers|models|views or
/app/sitechips/plugins/articles/controllers|models|views

as url-structure I need

www.mysite.de/sitechips/auth/login => core functionality
www.mysite.de/sitechips/article/add => content module, i.E. plugin
www.mysite.de/sitechips/article/edit/0815

What I have to do, in oder to get this calling-schema whith the shown
directory setup?

Thany you for your advice.

Axel


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



Freetag and Flickr / del.icio.us style tagging with Cake

2006-11-19 Thread [EMAIL PROTECTED]

Hi

has anyone done any tagging-style database in Cake? Where the users can
submit their own categories as in Flickr or del.icio.us?

Should Freetag work - an OOP PHP MySQL approach to tagging?
http://getluky.net/freetag/

cheers

Luke


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



Re: Any idea how global set layout for admin method and for other method other layout?

2006-11-19 Thread AD7six

Hi Petr

try:

if (isset($this->params[CAKE_ADMIN])) {
}

useful methods:
pr ($this); die;
get_defined_vars();
get_defined_constants();

HTH,

AD7six
Please note:
The manual/bakery is a good place to start any quest for info.
The cake search (at the time of writing) erroneously reports less/no
results for the google group.
The wiki may contain incorrect info - read at your own risk (it's
mainly user submitted) :)
You may get your answer quicker by asking on the IRC Channel (you can
access it with just a browser here: http://irc.cakephp.org).
On Nov 19, 3:48 pm, "Petr Vytlačil" <[EMAIL PROTECTED]> wrote:
> Any idea how global set layout for admin method and for other method
> other layout?
>
> Now its :
> --
> Controller.
>
> function admin_index(){
>$this->layout = 'admin';
> ..
>
> }function index(){
>$this->layout = 'public';
> ..
>
> }Its very boring set in all admin methods.
>
> Maybe resolution is in set beforeFilter in app_model but i dont know
> --any condition--
>
> function beforeFilter()
> {
>   if(--any condition--)
>   {
> $this->layout = 'admin';
>   }else
>   {
> $this->layout = 'public';
>   }
> 
> }Help please..


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



Re: simple cakePHP question

2006-11-19 Thread jhughes96

> _deleteHasMany will loop through the preferences and delete each one.
> This would be the recommended way of deleting preferences since it
> would be done by the model.

HI,
i've been looking at the API but I just don't see how I call
_deleteHasMany? I do not want to cascade delete to child associations
if I delete the master (in this case User). I want to delete ALL the
rows on the many side of the relationship (in my case 'preferences')
but the "one" side (the User) is not to be deleted.

Hopefully this makes sense...thanks for your help so far and starting
to make a bit of progress...


Joel


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



setting up URL

2006-11-19 Thread leamas

I have searched for an answer, but because I really don't know what to
search I didn't find an answer.

What I need is for my url to look like this:

www.example.com/products/action
however, what I'm getting now is:
www.example.com/app/products/action

What I don't get is when I first started, I installed it into a
development folder and it worked.  The URL looked like
development.example.com/products/action

How come in the development URL it doesn't show 'app' but if I want it
on my root it does?


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



Re: Self recursion problem

2006-11-19 Thread [EMAIL PROTECTED]

Go to the API and checkout the Model::findAllThreaded() method. It does
exactly what you are looking for.

In your controller, you should be able to replace findAll with
findAllThreaded.

findAllThreaded will look for a parent_id field, if it finds one, child
objects (sub-menus in your case) will be put in a separate array named
"children".

Use the debug output to see how the data is structured.

sc


On Nov 19, 8:30 am, "voriux" <[EMAIL PROTECTED]> wrote:
> Hi people,
>
> I would like to ask a noob question how to model this situation?
>
> I have table:
> menu
> (id pri_key int(5),
> name varchar(200),
> parent_id int(5))
>
> Data looks like this:
>
> 1,Home,0
> 2,Pages,0
> 3,First Page,2
> 4,Second Page,2
> 5,Contacts,0
>
> I would like to get recursion results, like this
>
> Home
> Pages
> - First Page
> - Second Page
> Contacts
> 
> Any opinions? Thanks in advance :)


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



Re: Quick and easy dispatcher for cron jobs

2006-11-19 Thread nate

Here, make it more useful: http://bakery.cakephp.org/


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



Any idea how global set layout for admin method and for other method other layout?

2006-11-19 Thread Petr Vytlačil

Any idea how global set layout for admin method and for other method
other layout?

Now its :
--
Controller.

function admin_index(){
   $this->layout = 'admin';
..
}

function index(){
   $this->layout = 'public';
..
}

Its very boring set in all admin methods.


Maybe resolution is in set beforeFilter in app_model but i dont know
--any condition--

function beforeFilter()
{
  if(--any condition--)
  {
$this->layout = 'admin';
  }else
  {
$this->layout = 'public';
  }
}

Help please..


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



Self recursion problem

2006-11-19 Thread voriux

Hi people,

I would like to ask a noob question how to model this situation?

I have table:
menu
(id pri_key int(5),
name varchar(200),
parent_id int(5))

Data looks like this:

1,Home,0
2,Pages,0
3,First Page,2
4,Second Page,2
5,Contacts,0


I would like to get recursion results, like this

Home
Pages
- First Page
- Second Page
Contacts

Any opinions? Thanks in advance :)


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



Re: tagErrorMsg annoyance

2006-11-19 Thread Richard

I will answer my own question :) $html->tagIsInvalid()

On Nov 17, 1:13 pm, "Richard" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have removed the styling information from the tagErrorMsg method, so
> that no automaginess happens when outputting messages.
>
> This does mean everytime I update cake I will have to update html.php
> ... are there any other options? Do you agree that having the
> flexibility in surpressing this style information is a good thing?
>
> Now I can do things like this now:
>
> // turns my input element background red on error
> $html->input('Enquire/name', array($html->tagErrorMsg('Enquire/name',
> 'style="background-color:red"')));


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



Re: Querying Question

2006-11-19 Thread [EMAIL PROTECTED]

I would definitely avoid the duplicate data scenario.

> I have a users table (that has user_id, first_name, last_name...etc)
> And a profile table (profile_id, user_id, country)
> And a friends table which has (friend_id, user_id profile_id)

Why does the friends table have profile_id?
If friend_id is pointing to a record in the users table, then there
would be no need to store the profile_id twice.
If friend_id is NOT pointing to a record in the users table, then I
have misunderstood your question and you can ignore the rest of this
post.

If I understand your problem correctly, you need a hasAndBelongsToMany
association which relates the users table to it's self.
Try renaming your friends table to users_friends, and then add this
association to your User model.

var $recursive = 2;
var $hasAndBelongsToMany = array('Friend' =>
   array('className'=> 'User',
 'joinTable'=> 'users_friends',
 'foreignKey'   => 'user_id',
 'associationForeignKey'=> 'friend_id',
 'conditions'   => '',
 'order'=> '',
 'limit'=> '',
 'uniq' => true,
 'finderQuery'  => '',
 'deleteQuery'  => '',
   )
   );


if it works correctly (it worked for me when I tested it) you should
find the friend records in the data returned from the User model.
So if your controller code looks like this:
$this->set('user', $this->User->read(null, $id));

Then your view code might look like this:

Friends






hasAndBelongsToMany associations can seem rather complicated if you're
not used to them. If you have trouble getting this code to work, you
should probably read the models chapter of the cake manual, and perhaps
some hasAndBelongsToMany tutorials.

I have seen this question before, but I don't think it was answered, so
please let me know it this works for you.

Good luck,
sc


On Nov 19, 7:23 am, "Mandy" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> This might not necessarily related to cake, but I would like to know
> what's the best way to do this.
>
> I have a users table (that has user_id, first_name, last_name...etc)
> And a profile table (profile_id, user_id, country)
> And a friends table which has (friend_id, user_id profile_id)
>
> Now on the profile page, for that particular profile, I query friends
> table to get the user_id's of all the friends and display their photos,
> because all photos are user_id.jpg, but now I want to display the
> user's first name as well but that is in the user's table.
>
> I have 2 approaches -
>
> 1) Put user_name also in the friends table
> 2) Loop through all friends and for every entry go to the user table to
> get the user first name
>
> What do you guys suggest?
>
> 2nd one will have lots of select queries whereas first one would just
> duplicate data?
> 
> Thanks in advance,
> Mandy.


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



RE: Querying Question

2006-11-19 Thread Adrian Godong

>From database normality PoV, you should stick with your current structure
(approach 2). Complexity of SELECT query should belong to CakePHP engine,
not yours.

If you have defined the Model Association correctly, CakePHP will also
retrieve related tables, so you shouldn't worry about how to query.

>From what I understand, you will have the following associations:

User hasOne Profile (and Profile belongsTo User)
User hasMany Friend (and Friend belongsTo User)

If you queried (findAll) a Profile, CakePHP will also fetch related User,
Friends, and Friends' User. CakePHP have a recursive limit of 3, that means
you can only get 3 associated tables from the current one. This is good
enough for your problem.

-Original Message-
From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf
Of Mandy
Sent: 19 Nopember 2006 19:24
To: Cake PHP
Subject: Querying Question


Hi,

This might not necessarily related to cake, but I would like to know
what's the best way to do this.

I have a users table (that has user_id, first_name, last_name...etc)
And a profile table (profile_id, user_id, country)
And a friends table which has (friend_id, user_id profile_id)

Now on the profile page, for that particular profile, I query friends
table to get the user_id's of all the friends and display their photos,
because all photos are user_id.jpg, but now I want to display the
user's first name as well but that is in the user's table.

I have 2 approaches -

1) Put user_name also in the friends table
2) Loop through all friends and for every entry go to the user table to
get the user first name

What do you guys suggest?

2nd one will have lots of select queries whereas first one would just
duplicate data?

Thanks in advance,
Mandy.




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



Querying Question

2006-11-19 Thread Mandy

Hi,

This might not necessarily related to cake, but I would like to know
what's the best way to do this.

I have a users table (that has user_id, first_name, last_name...etc)
And a profile table (profile_id, user_id, country)
And a friends table which has (friend_id, user_id profile_id)

Now on the profile page, for that particular profile, I query friends
table to get the user_id's of all the friends and display their photos,
because all photos are user_id.jpg, but now I want to display the
user's first name as well but that is in the user's table.

I have 2 approaches -

1) Put user_name also in the friends table
2) Loop through all friends and for every entry go to the user table to
get the user first name

What do you guys suggest?

2nd one will have lots of select queries whereas first one would just
duplicate data?

Thanks in advance,
Mandy.


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



Re: hasMany query question

2006-11-19 Thread [EMAIL PROTECTED]

Hmmm... Me thinks you have a logic problem.

If "Classification belongsTo Ad " and "Location belongsTo Ad" then
searching by both Location.id and Classification.id at the same time is
redundant, since they would both share (at most) exactly one parent.

So if "Classification belongsTo Ad ", then Classification has only one
parent, and you can simply do this:
$this->Ad->Classifications->recursive = 3;
$data =
$this->Ad->Classifications->findById($this->data['Classification']['id']);
$ad = $data['Ad'];

Or if "Location belongsTo Ad ", then Location has only one parent, and
you can simply do this:
$this->Ad->Location->recursive = 3;
$data = $this->Ad->Location->findById($this->data['Location']['id']);
$ad = $data['Ad'];

Back to the logic problem... If one ad can have more than one
classification, and many adds can share the same classification, then
you are not using the correct relationships.  Based on your question, I
suspect you should be using hasAndBelongsToMany. If you think this is
possible, read the model chapter of the cake manual again:
http://manual.cakephp.org/chapter/models   Otherwise, ignore my
response.

sc


On Nov 19, 12:18 am, "naryga" <[EMAIL PROTECTED]> wrote:
> Ok, I have 3 models:
> Ad, Classification, Location
> Ad hasMany Classification,Location
> Location belongsTo Ad
> Classification belongsTo Ad
> I want to be able to search for Ads based on the associated
> Classifications and Locations.  I've tried using something like:
> 
>  $this->Ad->findAll("Classification.id =
> {$this->data['Classification']['id']} AND Location.id =
> {$this->data['Location']['id']}");
> 
> But this results in: "SQL Error in model Post: 1054: Unknown column
> 'Classification.id' in 'where clause'"
> Using Debug: 3, I found that the problem seems to be that when
> searching on a model with hasMany associations, an SQL alias is not
> created for the associated modles (ie, Classification as
> classifications).  However, changing my where statment to
> classifications.id = ... Doesn't seem to help.
>
> If I only wanted to use one of the associated models to limit the
> results, I would use
> $this->Ad->Classifications->findAll("Classification.id =
> {$this->data['Classification']['id']}); which works just fine.   Is
> there some other way I should be doing this?  Thanks in advance!


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



Re: simple cakePHP question

2006-11-19 Thread Matt

My bad, I just realised I misread the question and you don't want to
delete the User object.


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



Re: simple cakePHP question

2006-11-19 Thread Matt

Hi Joel,

CakePHP makes this very easy for you. I'm assuming you've setup the
models so that User hasMany Preference and Preference belongsTo User.

To have it that CakePHP automatically deletes all the Preference
entries when you delete the parent User just set 'dependent' to true in
the hasMany array for User.

Cheers
Matt


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



Quick and easy dispatcher for cron jobs

2006-11-19 Thread Matt

There has been quite a few threads about the best way to run cron jobs
when using CakePHP. I had to do this for my own application and I am
happy with the result so I want to share it with everyone. I can't take
all the credit for this as it's based on Jason Lee's post in the
thread:
http://groups-beta.google.com/group/cake-php/browse_thread/thread/ff3ad3c9e1e40aab/

It involves hacking the dispatcher so you can call controller actions
via the command line. What you do is make a copy of index.php in
/app/webroot/, scroll to the bottom and when you come to the line -
require CORE_PATH.'cake'.DS.'bootstrap.php'; - replaces everything
below it with the following code:-

// Dispatch the controller action given to it
// eg c:\php4\cli\php cron_dispatcher.php /mailouts/send
if($argc == 2) {
$Dispatcher= new Dispatcher();
$Dispatcher->dispatch($argv[1]);
}

What this means is you can call controller actions from the command
line, so for example to call the send action in your mailouts
controller you just create a cron job like this:

php cron_dispatcher.php /mailouts/send

Hope people find this useful.


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



Re: simple cakePHP question

2006-11-19 Thread [EMAIL PROTECTED]

> What is the Cake way of deleting all the prefences for a User (but not
> the User itself) without having to loop over all the users prefences
> and call DELETE on the Preference model?

Look in the API at the model class. Specifically, checkout the del
method, and the _deleteHasMany method. There is a lot of stuff in the
API that you won't find anywhere else!

_deleteHasMany will loop through the preferences and delete each one.
This would be the recommended way of deleting preferences since it
would be done by the model.

Of course the other way would be:
$this->Preference->execute("DELETE FROM preferences WHERE user.id =
".$user_id);

But, if you have a "beforeDelete" method defined for the preference
model, the execute sql method would skip that logic.

sc


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



Re: Modeling database views

2006-11-19 Thread [EMAIL PROTECTED]

I think we have beat this to death... but I will add a couple more
things.

> I agree on general principle.  My question is about the wisdom of using
> db views within cake because it breaks the relationship model (for the
> want of a better term).  And I'm not sure how good or bad that is.

Using a view does not break the relationship model, it simply as
another model to the relationship.

> 4) It is not possible insert records into the VIEW, and I don't think
> updating the VIEW would ever be possible or even make sense.

It is possible to update/add records in some views. It depends on the
database, and the view. However, I would highly discourage this!

One very compelling reason to use (or not to use)  a view,  is
performance. Using Ralph's view example; It is probably faster to use a
view and let MySQL do the 5 joins and return the result, as opposed to
cake making 6 database calls. However, keep in mind that you might not
need all 5 joins every time. Using cake, you can unbind your
relationships at run time, reducing extraneous database work. But the
view will have the overhead of all five joins every time it is
accessed.

Of course my blind performances comparisons may not apply to your
situation. It would depend on the number of records, number of indexes,
types of data, hardware architecture, and the database server.

Finally, in as much is a view is only a convenience, it should only be
used if it simplifies your project.  If you find your self writing a
complex join, and using that sql through out your project, then it
might be a good idea to take that complexity and put it in a convenient
central location (the database).

sc

On Nov 19, 2:24 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I used a sql VIEW as the basis of an ordinary model in my first Cake
> project. It turned out to be helpful in reducing the complexity of some
> queries, and just generally making things easier to understand. I think
> VIEWs are a useful tool to use, but not a panacea for anything in
> particular. Whatever can be accomplished with a VIEW can also be
> accomplished without a VIEW, as far as I can see.
>
> I don't agree that sql VIEWs would necessarily be non-generic. An
> unadorned VIEW is pretty standard, I think.
>
> Here's an example of a VIEW definition in Mysql. I've added extra blank
> lines to clarify the structure. This particular VIEW is conceptually
> quite simple -- just a multi-table natural join -- but unfortunately
> SQL has a way of making things complicated.
>
> In fact, that's a good reason to consider using VIEWs. Complexity is
> hidden inside them, potentially making other parts of the the
> application simpler.
>
> ---
>
> CREATE VIEW courses_students_teachers_scheduleblocks
>
> AS
>
> select concat(courses_students.course_id,courses_students.student_id,
> courses.teacher_id,courses.scheduleblock_id) AS id,
>
> courses.scheduleblock_id AS scheduleblock_id,
> courses.id AS course_id,
> courses.subject AS subject,
> teachers.id AS teacher_id,
> teachers.teacher_fname AS teacher_fname,
> teachers.teacher_lname AS teacher_lname,
> students.id AS student_id,
> students.lname AS student_lname,
> students.fname AS student_fname from courses_students join
> students) join courses) join teachers) join scheduleblocks)
>
> WHERE ((courses.id = courses_students.course_id) and
> (courses_students.student_id = students.id) and (courses.teacher_id =
> teachers.id) and (scheduleblocks.id = courses.scheduleblock_id));
>
> ---
>
> And here is the corresponding model:
>
> ---
>
> class CoursesStudentsTeachersScheduleblock extends AppModel
> {
> var $name = 'CoursesStudentsTeachersScheduleblock';
>
> var $belongsTo = array(
> 'Scheduleblock' =>
>  array('className' => 'Scheduleblock',
> 'conditions' => '',
> 'order' => '',
> 'foreignKey' => '',
> 'counterCache' => ''),
>
> 'Course' =>
>  array('className' => 'Course',
> 'conditions' => '',
> 'order' => '',
> 'foreignKey' => '',
> 'counterCache' => ''),
>
> 'Teacher' =>
>  array('className' => 'Teacher',
> 'conditions' => '',
> 'order' => '',
> 'foreignKey' => '',
>