Re: Mysql GROUP in containable not working

2010-10-04 Thread Bryan Paddock
eeks... nobody at all? :(

On Wed, Sep 29, 2010 at 1:21 PM, Bryan Paddock bryanpadd...@gmail.comwrote:

 Hey all,

 Trying to use GROUP by in containable behaviour and it's not working as
 expected.

 Ratings model has fields: *Rating.id, Rating.restaurant_id, Rating.rating
 (1-5)*

 I have a query (which amongst other things) fetches the average + total
 ratings for a restaurant:

 $restaurant = $this-Restaurant-find('first', array(
 'fields' = array(Restaurant.x, Restaurant.y, Restaurant.z),
 'contain' = array(
 'model1' = array(x, y, z),
 *'Rating' = array(*
 *  'fields' = array(*
 *'AVG(Rating.rating)',*
 *'COUNT(Rating.id)'*
 *  )*
 *),*
 'model2' = ...
 )
 ));

 It works fine on my mysql version 5.0 on my dev server but as soon as I
 upload it onto live site mysql 4.1 I get error saying I *cannot mix group
 columns (avg, sum, etc) is illegal without a GROUPBY field.*

 So ok fair play, I'm not including a groupby field. I jumped in and added
 one:

 $restaurants = $this-Restaurant-find('all', array(
 'fields' = array(Restaurant.x, Restaurant.y, Restaurant.z),
 'contain' = array(
 'model1' = array(x, y, z),
 *'Rating' = array(*
 *  'fields' = array(*
 *'AVG(Rating.rating)',*
 *'COUNT(Rating.id)'*
 *  ),*
 *  'group' = 'Restaurant.id'   // I also tried 'group' =
 'id'*
 *),*
 'model2' = ...
 )
 ));



 Which I would figure works but it doesn't. I get an error saying that *there
 is no column called 'group'* and it is trying to execute this query:

 SELECT `Rating`.`restaurant_id`, AVG(`Rating`.`rating`),
 COUNT(`Rating`.`id`), `Rating`.`group` FROM `ratings` AS `Rating` WHERE
 `Rating`.`restaurant_id` = (5)

 Am I using containable incorrectly?





Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Mysql GROUP in containable not working

2010-09-29 Thread Bryan Paddock
Hey all,

Trying to use GROUP by in containable behaviour and it's not working as
expected.

Ratings model has fields: *Rating.id, Rating.restaurant_id, Rating.rating
(1-5)*

I have a query (which amongst other things) fetches the average + total
ratings for a restaurant:

$restaurant = $this-Restaurant-find('first', array(
'fields' = array(Restaurant.x, Restaurant.y, Restaurant.z),
'contain' = array(
'model1' = array(x, y, z),
*'Rating' = array(*
*  'fields' = array(*
*'AVG(Rating.rating)',*
*'COUNT(Rating.id)'*
*  )*
*),*
'model2' = ...
)
));

It works fine on my mysql version 5.0 on my dev server but as soon as I
upload it onto live site mysql 4.1 I get error saying I *cannot mix group
columns (avg, sum, etc) is illegal without a GROUPBY field.*

So ok fair play, I'm not including a groupby field. I jumped in and added
one:

$restaurants = $this-Restaurant-find('all', array(
'fields' = array(Restaurant.x, Restaurant.y, Restaurant.z),
'contain' = array(
'model1' = array(x, y, z),
*'Rating' = array(*
*  'fields' = array(*
*'AVG(Rating.rating)',*
*'COUNT(Rating.id)'*
*  ),*
*  'group' = 'Restaurant.id'   // I also tried 'group' = 'id'*
*),*
'model2' = ...
)
));



Which I would figure works but it doesn't. I get an error saying that *there
is no column called 'group'* and it is trying to execute this query:

SELECT `Rating`.`restaurant_id`, AVG(`Rating`.`rating`),
COUNT(`Rating`.`id`), `Rating`.`group` FROM `ratings` AS `Rating` WHERE
`Rating`.`restaurant_id` = (5)

Am I using containable incorrectly?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Dynamic menu based on deep relationships

2010-08-29 Thread Bryan Paddock
Hey all,

I've looked through pretty much every menu tutorial out there for cakephp
and have sat for ages to try and think up how I can achieve this but to no
avail.

I have a semi-complex database structure of establishments (restaurants,
hotels etc).

Province - Region - Suburb - Establishment

as well as

Category - Subcategory - Establishment

Now the user needs to be able to select the province from the list, have it
show the regions under that province, then the suburbs, then a list of
subcategories under that province that contain establishments. I can handle
the fetching the data (eg how to pull out the list using containable etc)
but it's the starting foundation I'm having problems figuring out. IT will
be done in ajax but the actual ajax part I could probably do myself.

I would like to have the menu also build itself from the page that the user
is on (eg the user can browse around the menu in itself but if he also goes
to the a related page (eg suburbs/view/cape-town) then the menu should know
where the user is)

I honestly can't think of even where I should start here. Building a menu is
simple in plain php with simple relationships but it's getting pretty tricky
with all the extra levels.

Does anyone have any advice on a starting point which I could work with...
I'm trying to make it extendable in the sense that I don't want to hard code
anything.

I'm starting to think it may be better off to handle the menu separately in
a menu model and update the menu on each of the related models afterSave(),
etc callback but that seems a bit unnecessary as it would just be duplicated
data.

Thanks in advance!

Bryan

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Custom prefix route not working with pagination when named parameters present

2010-07-07 Thread Bryan Paddock
Hey guys,

Having a weird problem here.

Have a basic function judge_index($type = null) that spits out a simple
listing. Basic $this-paginate(); function.

In the view I have:

$paginator-options(array('url'=array_merge(array('judge' = true),
$this-passedArgs)));

The judge_index gets called 2 ways. One with the $type variable and one
without. The $type variable simply adds one extra condition to the paginator
variable.

The paginator correctly renders the next/back links with the custom judge
route only when there are no other passedArgs present.

Without named parameters I get:

/judge/judgings/index/page:2

With parameters I get:

/judgings/index/page:2/type:disqualified/judge:1

How can I get it to correctly add the custom route with parameters?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Containable pagination query

2010-04-28 Thread Bryan Paddock
Ah dang.

Yeah in the end I made some custom queries to accomplish it.

Yoh what a pain.

On Tue, Apr 27, 2010 at 10:52 AM, WebbedIT p...@webbedit.co.uk wrote:

 Your not going to have a massive amount of joy with running
 calculations of this nature on the fly so I would be looking at
 counterCache and possibly implementing your own afterSave/Delete
 callback methods to add COUNT and SUM values direct into your tables
 that you can then easily group and order your values by.

 HTH

 Paul

 Check out the new CakePHP Questions site http://cakeqs.org and help others
 with their CakePHP related questions.

 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.comcake-php%2bunsubscr...@googlegroups.comFor
  more options, visit this group at
 http://groups.google.com/group/cake-php?hl=en


Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Containable pagination query

2010-04-26 Thread Bryan Paddock
Hey all,

I've almost reached the end of application and this last little bit is
really getting to me!

Can anyone shed some light?

Models:
Submission hasMany Judging which belongsTo Judge (and submission)

The submissions are entries submitted by students.
Judgings stores each judges scores they have entered for each submission.
(score_originality, score_overall, score_objective, score_technical)
Judges stores each judges info.

Submission table contains a semifinalist tinyint.
Judging contains a disqualified tinyint.

What I'm trying to do is perform a query to fetch all the submissions and
the total score as well as the number of judges that judged that submission.

Then I also need to fetch the top25/top50/top100 scoring submissions as well
as the number of judges+total score.

I've tried every combination of containable I can think of but I'm about to
pull my hair out here...

thanks guys!

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Correct places to insert authentication code

2010-04-23 Thread Bryan Paddock
Hey guys,

I'm having some difficulties with my authentication code. I'm wondering if
anyone can point me in the right direction.

I have 3 routes set. admin / adminjudge / judge.

admin + adminjudge are hardcoded logins as they will never change and use
the User model to authenticate.
judge uses the Judge model.

I have the judge working nicely and it uses the Judge model alright.

But something is a bit awol in my beforeFilter and isAuthorized etc code.

Where is the best place to put the code for my login process?

Upon logging in I need to ensure that I have set the correct layout (each
route uses its own layout) and I need to redirect the user to the correct
place upon login.

Where should it all go? At the moment I have very messy code in the
beforeFilter and isAuthorized but I'm not 100% clued up on where it should
all go.

Could someone shed some light on the situation?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Ajax Helper not respecting routes

2010-04-21 Thread Bryan Paddock
Hey all,

Weird problem. I have a ajax search form and retrieves submissions and
inserts them into a div.

The ajax is working although the controller does not respect the prefix.

?php
  echo $form-create('Submission');
  echo $form-input('search', array('class' = 'quicksearch'));
  echo $ajax-submit('Submit', array(
'class' = 'quicksearchsubmit',
'url'= '/judge/submissions/search',
'update' = 'submissions-list'));
  echo $form-end();
?

When I submit I get the cake error in the div with the full layout saying
that the search function is not available in the submissions controller.
Nothing about judge_search.

Routes are definitely working as I am logging in and using the routes
properly.

Anyone having this same prob?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Quick habtm problem

2010-04-14 Thread Bryan Paddock
Hey all,

Going a bit crazy here I think I need a break from this. Anyways,

I have the following tables + relationships

Judges
MediaSegments (a category that the judge is selected to judge)
JudgesMediaSegments (contains judge_id and media_segment_id)

How would I find all the judges that belong to a specific media segment?

I know its something really simple I just cannot seem to get it right.

Thanks

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

To unsubscribe, reply using remove me as the subject.


Re: Multiple prefix routes. Second route not working.

2010-04-14 Thread Bryan Paddock
Damn, still trying to figure this out.

I did make some headway although I still get the error where its looking for
the prefixroute_controller instead of the real_controller with the
prefixroute_action function.

Anybody with any ideas?

On Wed, Apr 14, 2010 at 2:02 AM, Bryan Paddock bryanpadd...@gmail.comwrote:

 Hey all,

 I have an application that has been running for a while using admin
 routing. There are normal users as well as admin users.

 Now the application is growing and I need to create separate judging routes
 for judges that will log in and moderate the submissions.

 In my *core.php* I have the following line:

 Configure::write('Routing.admin', 'admin');

 To which I added the new one:

 Configure::write('Routing.judge', 'judge');

 In my *routes.php* I have the following route:

 Router::connect('/admin', array('controller' = 'submissions', 'action' =
 'control', 'admin' = true), array('language' = 'us'));

 To which I added the judging one:

 Router::connect('/judge', array('controller' = 'submissions', 'action' =
 'control', 'judge' = true), array('language' = 'us'));

 *submissions_controller.php* has the admin_control function which works.
 The judge_control does not.

 In fact the whole route is broken. Upon trying to access *site.com/judge* I
 get the error about SubmissionsController:control() not found.

 Does anyone know why it would not be trying to access
 SubmissionsController:judge_control() ?


Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

To unsubscribe, reply using remove me as the subject.


Re: Quick habtm problem

2010-04-14 Thread Bryan Paddock
Ah! Thank you!

After a while of tinkering with your code I realised I had the $actsAs in
the controller and not the model :(

Works like a charm. I've modified all of my code now to use containable
behaviour. Gone with recursive = -1.

On Wed, Apr 14, 2010 at 3:45 PM, Jeremy Burns jeremybu...@me.com wrote:

Are you using Containable behaviour? You should be!

 Try this...(typed without testing - so go easy on me if it's wrong!)...

 From the MediaSegment controller:

 $this-MediaSegment-find(
  'all',
 array(
 'contain' = array(
 'Judge'
  ),
 'conditions' =array(
 'MediaSegment.id' = $id
  )
 )
 );

 From the judges controller:

 $this-Judge-MediaSegment-find(
  'all',
 array(
 'contain' = array(
 'Judge'
  ),
 'conditions' =array(
 'MediaSegment.id' = $id
  )
 )
 );

 From within a model, just omit the first Model in the find statement (so
 $this-find())


  Jeremy Burns
 jeremybu...@me.com jeremybu...@mac.com


 On 14 Apr 2010, at 14:37, Bryan Paddock wrote:

 Hey all,

 Going a bit crazy here I think I need a break from this. Anyways,

 I have the following tables + relationships

 Judges
 MediaSegments (a category that the judge is selected to judge)
 JudgesMediaSegments (contains judge_id and media_segment_id)

 How would I find all the judges that belong to a specific media segment?

 I know its something really simple I just cannot seem to get it right.

 Thanks


 Check out the new CakePHP Questions site http://cakeqs.org and help others
 with their CakePHP related questions.

 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


  Check out the new CakePHP Questions site http://cakeqs.org and help
 others with their CakePHP related questions.

 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.comcake-php%2bunsubscr...@googlegroups.comFor
  more options, visit this group at
 http://groups.google.com/group/cake-php?hl=en


Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

To unsubscribe, reply using remove me as the subject.


Multiple prefix routes. Second route not working.

2010-04-13 Thread Bryan Paddock
Hey all,

I have an application that has been running for a while using admin routing.
There are normal users as well as admin users.

Now the application is growing and I need to create separate judging routes
for judges that will log in and moderate the submissions.

In my *core.php* I have the following line:

Configure::write('Routing.admin', 'admin');

To which I added the new one:

Configure::write('Routing.judge', 'judge');

In my *routes.php* I have the following route:

Router::connect('/admin', array('controller' = 'submissions', 'action' =
'control', 'admin' = true), array('language' = 'us'));

To which I added the judging one:

Router::connect('/judge', array('controller' = 'submissions', 'action' =
'control', 'judge' = true), array('language' = 'us'));

*submissions_controller.php* has the admin_control function which works. The
judge_control does not.

In fact the whole route is broken. Upon trying to access *site.com/judge* I
get the error about SubmissionsController:control() not found.

Does anyone know why it would not be trying to access
SubmissionsController:judge_control() ?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

To unsubscribe, reply using remove me as the subject.


Re: Containable query

2009-12-08 Thread Bryan Paddock
Aahhh.. good idea... I'll try that in the morning and see how it works
out...

thanks!

On Sat, Dec 5, 2009 at 2:35 PM, Tonu Tusk lvot...@googlemail.com wrote:

 ok - probably not the most efficient, but the following should work if
 your relationships are setup in the models

 $submissions = $this-Submission-find('all', array('fields' = array
 ('DISTINCT student_id'), 'recursive' = -1);
 $student_ids =Set::extract($submissions, '/Submission/student_id');
 // this gets an array of student Ids that do have submissions

 $contains = array('User' = array('fields' = array('id'))); //
 whatever other fields you want from your User record in here, or just
 leave the fields parameter out to retrieve all User fields
 $conditions = array('NOT' = array('Student.id' = $student_ids));
 $students = $this-Student-find('all', array('conditions' =
 $conditions, 'contain' = $contains, 'fields' = array('id)));
 // this gets the Student records (trimmed down to just id) whose ids
 are not in the list of student ids with submissions
 // the resulting dataset for each student will also have a User entry
 relating to the related associated User  record.

 // change the find call on the Student Model to list if you only want
 ids, or alter the containable parameters if you are working on the
 resulting dataset directly
 // OR use some set::extract functions to tailor the results you need.



 On Dec 4, 5:15 pm, abryant a...@tysonsteele.com wrote:
  You might also try (from the book.cakephp.org page on Containable)
 
  $list = $this-User-find('all', array(
'contain' = array(
  'Student' = array(
'Submission.student_id' = null
  )
)
  ));
 
  At least according to the examples in the manual this is an appropriate
 way
  to filter conditionally on a specific field in a contained relationship
  --
  View this message in context:
 http://n2.nabble.com/Containable-query-tp4057992p4113719.html
  Sent from the CakePHP mailing list archive at Nabble.com.

 Check out the new CakePHP Questions site http://cakeqs.org and help others
 with their CakePHP related questions.

 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.comcake-php%2bunsubscr...@googlegroups.comFor
  more options, visit this group at
 http://groups.google.com/group/cake-php?hl=en


Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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: Containable query

2009-12-02 Thread Bryan Paddock
Hmm... nobody have any ideas?

On Tue, Nov 24, 2009 at 4:05 PM, Bryan Paddock bryanpadd...@gmail.comwrote:

 Hey all,

 I have this relationship in question:

 User - hasOne Student - hasMany Submission

 I'm a bit stumped on how I can fetch all the users who do not have any
 submissions linked to their name.

 I've tried:

 $list = $this-User-find('all', array(
   'contain' = array(
 'Student' = array(
   'Submission' = array(
 'conditions' = array(
   'Submission.student_id' = null
 )
   ),
 )
   )
 ));

 I have the actAs in the model so the containable behaviour is functioning -
 there is just a problem with my specific query.

 Any ideas?

 thanks!


Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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


Containable query

2009-11-24 Thread Bryan Paddock
Hey all,

I have this relationship in question:

User - hasOne Student - hasMany Submission

I'm a bit stumped on how I can fetch all the users who do not have any
submissions linked to their name.

I've tried:

$list = $this-User-find('all', array(
  'contain' = array(
'Student' = array(
  'Submission' = array(
'conditions' = array(
  'Submission.student_id' = null
)
  ),
)
  )
));

I have the actAs in the model so the containable behaviour is functioning -
there is just a problem with my specific query.

Any ideas?

thanks!

--

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-...@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.




Grouping query

2009-10-15 Thread Bryan Paddock
Hey guys,
I'm trying to figure out how best to go about doing reports for my current
project.

It's a website where artists upload their work and then judges make rate +
comment etc. My query is in the reporting section.

The main model is the Submission model.

Submission belongsTo Student, Category, Competition
Student belongsTo User, Country

I'm trying to find out how to group by school (Student.school field). Each
submission is tied to the student row by a Submission.student_id field.

ie show each unique school and how many submissions there are for that
school.

Thanks,
Bryan

--~--~-~--~~~---~--~~
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: Grouping query

2009-10-15 Thread Bryan Paddock
Basically I'm just looking for a little finger pointing in the right
direction...
output of a submission - http://pastebin.com/f221f94c1

I'm trying to do some reporting based on a few related model fields

eg by school, by country, by category etc. each must also be grouped by all
the years too.

I'm dreading the submissions by week report...

Any pointers would be great... I'm trying to leave as much up to the sq


On Thu, Oct 15, 2009 at 4:18 PM, Bryan Paddock bryanpadd...@gmail.comwrote:

 Hey guys,
 I'm trying to figure out how best to go about doing reports for my current
 project.

 It's a website where artists upload their work and then judges make rate +
 comment etc. My query is in the reporting section.

 The main model is the Submission model.

 Submission belongsTo Student, Category, Competition
 Student belongsTo User, Country

 I'm trying to find out how to group by school (Student.school field). Each
 submission is tied to the student row by a Submission.student_id field.

 ie show each unique school and how many submissions there are for that
 school.

 Thanks,
 Bryan


--~--~-~--~~~---~--~~
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: Grouping query

2009-10-15 Thread Bryan Paddock
argh gmail hotkeys irritate me...
continuing mail...



Im trying to leave as much up to the sql server as possible and reduce the
number of separate queries I run. I could probably accomplish all of these
reports with 100's of queries all handled in the controller but that would
get progressively slower should the db fill up...

thanks!

On Thu, Oct 15, 2009 at 4:54 PM, Bryan Paddock bryanpadd...@gmail.comwrote:

 Basically I'm just looking for a little finger pointing in the right
 direction...
 output of a submission - http://pastebin.com/f221f94c1

 I'm trying to do some reporting based on a few related model fields

 eg by school, by country, by category etc. each must also be grouped by all
 the years too.

 I'm dreading the submissions by week report...

 Any pointers would be great... I'm trying to leave as much up to the sq


 On Thu, Oct 15, 2009 at 4:18 PM, Bryan Paddock bryanpadd...@gmail.comwrote:

 Hey guys,
 I'm trying to figure out how best to go about doing reports for my current
 project.

 It's a website where artists upload their work and then judges make rate +
 comment etc. My query is in the reporting section.

 The main model is the Submission model.

 Submission belongsTo Student, Category, Competition
 Student belongsTo User, Country

 I'm trying to find out how to group by school (Student.school field). Each
 submission is tied to the student row by a Submission.student_id field.

 ie show each unique school and how many submissions there are for that
 school.

 Thanks,
 Bryan




--~--~-~--~~~---~--~~
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: Finding deeply related models

2009-09-10 Thread Bryan Paddock
Ah-ha! Containable worked a charm!
thanks!

On Wed, Sep 9, 2009 at 5:42 PM, Dave Maharaj :: WidePixels.com 
d...@widepixels.com wrote:

  Why not use contain?

 'contain' = array(
 'Property' = array(
  'conditions' = array(
 'Property.id' = $foo),
  'fields' = array(
'Property.field1,
'Property.field2')),
 'Country' = array(
 'fields' = array(
'Country.name';

 Something along those lines.

  --
 *From:* Bryan Paddock [mailto:bryanpadd...@gmail.com]
 *Sent:* September-09-09 12:42 PM
 *To:* cake-php@googlegroups.com
 *Subject:* Re: Finding deeply related models

 Oh no ways
 Hmm..

 $this-Property-recursive = 1;
 pr($this-Property-find('all'));

 and it prints out the properties without extended associated data...

  $this-Property-recursive = 2;
 pr($this-Property-find('all'));

 and it returns nothing at all...

 hmmm let me look through my models - maybe I have some code in the
 callbacks which is causing problems...

 On Wed, Sep 9, 2009 at 5:07 PM, grigri j...@hendersonwebdesign.com wrote:


 Where on earth did you get that idea?

 See: http://book.cakephp.org/view/439/recursive

 Check the model tests in the source, there are many examples of
 setting recursive to 2, 3, and even 6 (in the testReadFakeThread
 method).

 hth
 grigri

 On Sep 9, 4:01 pm, Bryan Paddock bryanpadd...@gmail.com wrote:
  recursive only accepts 3 values... -1 / 0 / 1
  Tried that :(
 
   On Wed, Sep 9, 2009 at 4:57 PM, grigri j...@hendersonwebdesign.com
 wrote:
 
   Set recursive to 2?
 
   On Sep 9, 3:21 pm, Bryan Paddock bryanpadd...@gmail.com wrote:
Hey all,
How can I get cake to retrieve deeply related info?
 
*Property *belongsTo *Location *which in turn belongsTo *Country*
 
How can I get $this-Property-find(xx) to return the Country as
 well?
 
I'm having the same problem with *Property *belongsTo *Seller *which
belongsTo *User *(every time I retrieve data for property I have to
 fetch
the User row manually)
 
Its happening in all of my finds - It only goes one level deep...
 
Any ideas? I've tried setting recursive to 1...
 
Bryan
 
 


 


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Finding deeply related models

2009-09-09 Thread Bryan Paddock
Hey all,
How can I get cake to retrieve deeply related info?

*Property *belongsTo *Location *which in turn belongsTo *Country*

How can I get $this-Property-find(xx) to return the Country as well?

I'm having the same problem with *Property *belongsTo *Seller *which
belongsTo *User *(every time I retrieve data for property I have to fetch
the User row manually)

Its happening in all of my finds - It only goes one level deep...

Any ideas? I've tried setting recursive to 1...

Bryan

--~--~-~--~~~---~--~~
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: Finding deeply related models

2009-09-09 Thread Bryan Paddock
recursive only accepts 3 values... -1 / 0 / 1
Tried that :(

On Wed, Sep 9, 2009 at 4:57 PM, grigri j...@hendersonwebdesign.com wrote:


 Set recursive to 2?

 On Sep 9, 3:21 pm, Bryan Paddock bryanpadd...@gmail.com wrote:
  Hey all,
  How can I get cake to retrieve deeply related info?
 
  *Property *belongsTo *Location *which in turn belongsTo *Country*
 
  How can I get $this-Property-find(xx) to return the Country as well?
 
  I'm having the same problem with *Property *belongsTo *Seller *which
  belongsTo *User *(every time I retrieve data for property I have to fetch
  the User row manually)
 
  Its happening in all of my finds - It only goes one level deep...
 
  Any ideas? I've tried setting recursive to 1...
 
  Bryan
 


--~--~-~--~~~---~--~~
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: Finding deeply related models

2009-09-09 Thread Bryan Paddock
Oh no ways
Hmm..

$this-Property-recursive = 1;
pr($this-Property-find('all'));

and it prints out the properties without extended associated data...

$this-Property-recursive = 2;
pr($this-Property-find('all'));

and it returns nothing at all...

hmmm let me look through my models - maybe I have some code in the callbacks
which is causing problems...

On Wed, Sep 9, 2009 at 5:07 PM, grigri j...@hendersonwebdesign.com wrote:


 Where on earth did you get that idea?

 See: http://book.cakephp.org/view/439/recursive

 Check the model tests in the source, there are many examples of
 setting recursive to 2, 3, and even 6 (in the testReadFakeThread
 method).

 hth
 grigri

 On Sep 9, 4:01 pm, Bryan Paddock bryanpadd...@gmail.com wrote:
  recursive only accepts 3 values... -1 / 0 / 1
  Tried that :(
 
  On Wed, Sep 9, 2009 at 4:57 PM, grigri j...@hendersonwebdesign.com
 wrote:
 
   Set recursive to 2?
 
   On Sep 9, 3:21 pm, Bryan Paddock bryanpadd...@gmail.com wrote:
Hey all,
How can I get cake to retrieve deeply related info?
 
*Property *belongsTo *Location *which in turn belongsTo *Country*
 
How can I get $this-Property-find(xx) to return the Country as
 well?
 
I'm having the same problem with *Property *belongsTo *Seller *which
belongsTo *User *(every time I retrieve data for property I have to
 fetch
the User row manually)
 
Its happening in all of my finds - It only goes one level deep...
 
Any ideas? I've tried setting recursive to 1...
 
Bryan
 
 
 


--~--~-~--~~~---~--~~
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: Regex validation problem.

2009-09-01 Thread Bryan Paddock
Ah in the end I removed the validation completely... realized that putting
such restrictions on names is not the best idea (eg unicode chinese/jap
names etc)
On Mon, Aug 31, 2009 at 5:14 PM, Dr. Loboto drlob...@gmail.com wrote:


 Your function does all right - alphanumeric values only as you did
 nothing with it.

 '/^[a-zA-Z0-9_-]+$/'
 


--~--~-~--~~~---~--~~
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: Pulling in another table in a find query

2009-08-31 Thread Bryan Paddock
I have a slight workaround at the moment... I'm converting the area geometry
box to a text field and then performing the search
$area = $this-Property-Seller-Agency-Channel-Area-find('first',
array(
  'conditions'  = array('Area.id' = $areaId),
  'fields'  = 'AsText(ExteriorRing(`Area`.`area_box`)) as polygon,
Country.name, Area.*',
));

then

$this-paginate['conditions'] = array('MBRContains('
.$area[0]['polygon'] . ',`Location`.`location_point`)');
$data = $this-paginate('Property');

But ideally it would be better to perform just one query instead of two...

On Mon, Aug 31, 2009 at 10:28 AM, Bryan Paddock bryanpadd...@gmail.comwrote:

 Hi there,
 No, properties do not have an associated area ID. Properties are located
 via their location_id.

 Area ID's are used in another portion of the site but in this case it is
 necessary to do a search on area's instead of locations.

 Lemme give the full picture to explain it more...

 Properties are located by a location ID pointing to a location table which
 has the geomeotric points store in it. Those are single addresses of each
 property.
 Now agencies can request channels where they can purchase different
 suburbs. Those suburbs are stored in the areas table and assigned to each
 channel via a join areas_channels.

 What I need to accomplish now is I need to be able to search for all
 properties that belong to an agencies channel that are in the channel's
 areas they have purchased. Hence the area not being directly related to the
 properties.

 I can't assign an area_id to a property as the area has nothing to do with
 the property.

 I'm thinking I may need to do some custom sql magic here


 On Fri, Aug 28, 2009 at 5:22 PM, brian bally.z...@gmail.com wrote:


 - What I need to do now is to fetch all the properties which are
 inside a certain area id.

 Property belongsTo Area. That is, the properties table should have an
 area_id column.

 On Fri, Aug 28, 2009 at 7:02 AM, Bryan Paddockbryanpadd...@gmail.com
 wrote:
  Hey all,
  I'm trying to execute a query including a table which is not related.
 I'm
  not sure how I can go about doing this...
  3 models in question:
  property (which has a location_id field)
  location (which has a location_point field stored as geometry point)
  area (which has an area_box field stored as a polygon)
  The location table is used to store single one to one locations for the
  properties. The area table is used to store suburbs etc for another part
 of
  the site.
  What I need to do now is to fetch all the properties which are inside a
  certain area id. Sounds simple enough but I just cant figure it out.
 Area
  has no relation to property and should not.
  The query would be something like this (I'm just writing out what the
 sql
  should look like... I'm not using raw sql in my cake app)
  select
p.*,
a.*,
l.*
  from
properties p,
areas a
  left join
location l
  on
p.location_id = l.id
  where
a.id = 5
  and
MBRContains(a.area_box, l.location_point)
  so bascially fetch all properties where it's associated
  locations.location_point is inside a specific unassociated
 areas.area_box
  identified by its areas.id.
  In my property query conditions I have set array('Area.id' = 5) but
 because
  it is not a directly related model cake isn't including that table in
 the
  query so its failing with an unknown table Area...
  Even if I add Area.area_box to the 'fields' array for the paginator it
  still doesn't know to fetch info from the area table.
  How do I tell cakephp to include an unrelated table into the query? var
  $uses = array('Area') was useless
  
 

 



--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Regex validation problem.

2009-08-31 Thread Bryan Paddock
Hey guys,
Having a weird problem here... In my validation everything was working fine
except now I needed to change the first + surname validation fields to allow
for spaces + dashes. It was originally just working on only alphanumeric
characters. The dashes + underscores was an extra addition added now.

Here is the first name section of the $this-validation variable: (copied
directly from the cakephp book even...)

*// First name:*
*//  - cannot be empty*
*//  - must be alphanumeric*
*
*
*'name_first' = array(*
*  'name_first-1' = array(*
*'rule'   = 'alphaNumericDashUnderscore',*
*'message'= 'First name can only contain alphanumeric
characters and dashes'*
*  ),*
*
*
*  'name_first-2' = array(*
*'rule'  = 'notEmpty',*
*'message'   = 'Please enter your firstname'*
*  )*
*)*

and I have the function:

*  function alphaNumericDashUnderscore($data)*
*  {*
*$value = array_values($data);*
*$value = $value[0];*
**
*return preg_match('/^[a-zA-Z0-9]+$/', $value);*
*  }*

Yet the validation still comes back as a failure each time... I can't figure
this out... it should be rather simple but I just can't get it...

--~--~-~--~~~---~--~~
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: redirect after download dialog

2009-08-28 Thread Bryan Paddock
If you really need to do that you may be able to accomplish it by providing
the file download inside an iframe and then redirecting the main window...
I haven't tried this... it's just an idea...

On Fri, Aug 28, 2009 at 3:15 AM, brian bally.z...@gmail.com wrote:


 You can't. In order to have the browser present the user with a save
 dialog, certain headers need to be sent. By the time that's happened,
 it's too late to send a redirect header.

 On Thu, Aug 27, 2009 at 5:35 PM, Martin Radostamartinrado...@gmail.com
 wrote:
 
  Let's say I have a view that renders an excel file to download. It
  presents a download dialog to the user. This user can decide to save the
  file to the local drive, to open the file or to cancel the operation.
  Now I need to redirect somewhere else after any operation with the
  download dialog.
 
  Does anybody knows how to do this?
 
  Thnks
 
  MARTIN
 
  
 

 


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Pulling in another table in a find query

2009-08-28 Thread Bryan Paddock
Hey all,
I'm trying to execute a query including a table which is not related. I'm
not sure how I can go about doing this...

3 models in question:

property (which has a location_id field)
location (which has a location_point field stored as geometry point)
area (which has an area_box field stored as a polygon)

The location table is used to store single one to one locations for the
properties. The area table is used to store suburbs etc for another part of
the site.

What I need to do now is to fetch all the properties which are inside a
certain area id. Sounds simple enough but I just cant figure it out. Area
has no relation to property and should not.

The query would be something like this (I'm just writing out what the sql
should look like... I'm not using raw sql in my cake app)

select
  p.*,
  a.*,
  l.*
from
  properties p,
  areas a
left join
  location l
on
  p.location_id = l.id
where
  a.id = 5
and
  MBRContains(a.area_box, l.location_point)

so bascially fetch all properties where it's associated
locations.location_point is inside a specific unassociated areas.area_box
identified by its areas.id.

In my property query conditions I have set array('Area.id' = 5) but because
it is not a directly related model cake isn't including that table in the
query so its failing with an unknown table Area...

Even if I add Area.area_box to the 'fields' array for the paginator it
still doesn't know to fetch info from the area table.

How do I tell cakephp to include an unrelated table into the query? var
$uses = array('Area') was useless

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



HABTM not saving

2009-08-24 Thread Bryan Paddock
Hey all,
Ok I'm pulling my hair out here.

HABTM save/edit/removes are not happening.

I have two models. Channel and Area. The model definitions are configured
properly (channel: *var $hasAndBelongsToMany = array( 'Area' )* and area: *var
$hasAndBelongsToMany = array( 'Channel' )* )

I have no clue why this is not working because I am not getting any error
messages back from cake at all.

I am calling validates() before save() and it validates but it does not
save.

I am trying to save this array

$data =

Array
(
[Channel] = Array
(
[id] = 16
)

[Area] = Array
(
[0] = Array
(
[id] = 14
)

)

)

I have tried saving this too

Array
(
[Channel] = Array
(
[id] = 16
)

[Area] = Array
(
[0] = 14
)

)

Is there something I am doing incorrectly? When I push debug level up
to 3 I can see cake is not even trying to do any of the habtm queries.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



HABTM Delete problem

2009-08-18 Thread Bryan Paddock
Hey all,
I'm having a strange problem - My HABTM relationship seems to be working out
alright except I cannot remove the last remaining entry.

This is the situation:

areas
channels
areas_channels

I have no problem in adding ares to channels. I can remove areas from
channels too... I just cannot remove the last area assigned to a channel.

I have:

$channel =

[Channel] = Array(
  [id], etc etc
)

[Area] = Array(
)

$this-Channel-save($channel);

And that saves without a problem except it does not remove all the areas
from that channel.

Is there something I am missing?

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



CakePHP and mysql spatial data types

2009-07-22 Thread Bryan Paddock
Hey all,
Anyone had any joy with the mysql spatial extensions data types?

eg POINT/ LINE/ etc?

I can't see any way around this other than custom sql commands...

Bryan

--~--~-~--~~~---~--~~
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: Setting up table ID's

2009-07-15 Thread Bryan Paddock
What is the purpose of the UUID? The database generates a unique ID for each
user anyways so if it's just for internal usage then just use the ID.
If you need a UUID then i'd recommend adding an extra field in the db for
it.

The correct way to go about it would involve the use of foregin keys.

---

Users
---
id
uuid
name
email
other_fields

Profiles
-
id
user_id  - foreign key for the User.id field
other_fields

Galleries
---
id
user_id - foreign key for the User.id field
gallery_name

Albums
--
id
gallery_id- foreign key for the Gallery.id field
album_name

---

If you need to fetch the users galleries then you'll call

$this-User-Gallery-find('all', array('conditions' = array(
'Gallery.user_id' = $this-Auth-user('id') ) );

And if your model's are associated properly then you'll fetch all the albums
related to that gallery too.

Hope this helps.


On Mon, Jul 13, 2009 at 9:36 PM, Dave Maharaj :: WidePixels.com 
d...@widepixels.com wrote:

  I am setting up am app and trying UUID for each user but question I have
 is:

 So a User.id is a UUID
 that User hasOne Profile.id which will be the User.id correct?

 User.id = same as = Profile.id

 And say a User hasOne Gallery which hasMany Albums and each Album hasMany
 Photos

 Would the Gallery.id be the User.id? the Album has its own ID, gallery_id
 which would be the same UUID?

 User.id = same as = Gallery.id

 Album.id = int(11)
 Album.gallery_id = the users UUID

 Photos.id = int(11)
 Photos.album_id = int(11)

 and
 Photos would have their own ID but relate back to the album_id whichc would
 trace back to the Gallery.id and back to its original owner?

 Hope that makes sense

 Is that the right way to do it?

 Thanks,

 Dave

 


--~--~-~--~~~---~--~~
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: Simple relationship problem

2009-06-30 Thread Bryan Paddock

Hey JD,

Ah... I'm confused as to why I would need a HABTM and a join table for
a fairly simple relationship.

example of the structure:

Seller.id
Seller.name
Seller.agency_id
etc

and

Agency.id
Agency.name
etc

Each seller can only belong to one agency.
Each agency can have any number of sellers.

I've defined $hasOne and $belongsTo but cake complains that there is
no agency.seller_id field which is correct because that would imply
that each agency can only have one seller.

Hm.

On Mon, Jun 29, 2009 at 8:25 PM, JD Danielsj...@internetguys.ca wrote:
 You need to look at hasAndBelongsToMany

 http://book.cakephp.org/view/83/hasAndBelongsToMany-HABTM

 Bryan Paddock wrote:

 Argh.. I hate gmail shortcut keys.

 Anyways continuing mail:

 Heya all,

 Theres something I'm not doing right here...

 I have a User model which has one Seller model linked to it which in
 turn can have an Agency model linked to it.

 User Model:
 hasOne seller.

 Seller Model:
  belongsTo user

 Agency Model:
 belongsTo seller

 Now when I call $this-User-find('all') it complains that there is no
 foreign key in the agency table. That would be impossible because then
 that would mean only one agency can belong to one seller.

 How do I set it up so that any number of agencies can belong to any
 number of sellers? I'm missing something really stupid here

 Thanks!

 Bryan






 On Mon, Jun 29, 2009 at 7:06 PM, Bryan Paddockbryanpadd...@gmail.com
 wrote:


 Heya all,

 Theres something I'm not doing right here...

 I have a User model which has one Seller model linked to it which in
 turn can have an Agency model linked to it.

 User Model:
 hasOne seller.
 Seller Model: belongsTo user
 Agency Model: belongsTo seller





 


--~--~-~--~~~---~--~~
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: Pagination not respecting page numbers

2009-06-30 Thread Bryan Paddock

Heya,

Ahh I figured out what the problem was...

I had

$data = $this-paginate('Property', $conditions, $fields, $theorder,
$resultsperpage, $page);

but the paginate function doesn't take those parameters...

I had to use:

$this-paginate = array(
  'limit' = $resultsperpage,
  'order' = $theorder,
  'fields'= $fields,
  'page'  = $page
);

$data = $this-paginate('Property');

oops!

On Wed, Jun 24, 2009 at 9:16 PM, schneimimichael.schne...@arcor.de wrote:

 Hi,

 I am not sure about your problem, but I also use named params and can
 tell you how to pass them to the next pages without a session
 workaround.

 Well, but you can also do it with the session, the only thing you have
 to do, is to pass the named parameters to the pagination functions
 with the url option.

 For not using the session, you can define the options in the
 controller with the incoming params like this

    $this-set('paginationOptions', array('url' = array('title:'.
 $this-params['named']['title'],

 'year:'.$this-params['named']['year'])));

 and then pass the options to the pagination functions that you use in
 the view, like $paginator-numbers($options),...

 Hope this helps,

 Michael

 On 24 Jun., 20:44, Bryan Paddock bryanpadd...@gmail.com wrote:
 Hey all,

 I was using the paginator and it was working pretty well for me when I
 was using all the search criteria as named url parameters. I
 discovered that the paginator didn't send the parameters to the next
 pages so implemented sessions to store the criteria.

 The arrays I create from the session (critera/order) generate fine and
 the page number variable I take from the named url parameter.

 examples of values follow

 $conditions = Array
 (
     [sale] = 1
 )

 $theorder = Array
 (
     [created_date_time] = DESC
 )

 $resultsperpage = 10;

 $page = 1; // or 2, 3, etc

 My paginator call is:

 $data = $this-paginate('Property', $conditions, $theorder,
 $resultsperpage, $page);

 For some reason it respects the conditions, order and results per page
 but NOT the page number. Anyone have any ideas why? I test the value
 of the $page variable and it does correctly change but the data
 received from the model remains the same.

 Am I doing something wrong here? I can't figure out what's going on

 thanks!
 bryan
 


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Simple relationship problem

2009-06-29 Thread Bryan Paddock

Heya all,

Theres something I'm not doing right here...

I have a User model which has one Seller model linked to it which in
turn can have an Agency model linked to it.

User Model:
hasOne seller.
Seller Model: belongsTo user
Agency Model: belongsTo seller

--~--~-~--~~~---~--~~
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: Simple relationship problem

2009-06-29 Thread Bryan Paddock

Argh.. I hate gmail shortcut keys.

Anyways continuing mail:

Heya all,

Theres something I'm not doing right here...

I have a User model which has one Seller model linked to it which in
turn can have an Agency model linked to it.

User Model:
hasOne seller.

Seller Model:
 belongsTo user

Agency Model:
belongsTo seller

Now when I call $this-User-find('all') it complains that there is no
foreign key in the agency table. That would be impossible because then
that would mean only one agency can belong to one seller.

How do I set it up so that any number of agencies can belong to any
number of sellers? I'm missing something really stupid here

Thanks!

Bryan






On Mon, Jun 29, 2009 at 7:06 PM, Bryan Paddockbryanpadd...@gmail.com wrote:
 Heya all,

 Theres something I'm not doing right here...

 I have a User model which has one Seller model linked to it which in
 turn can have an Agency model linked to it.

 User Model:
 hasOne seller.
 Seller Model: belongsTo user
 Agency Model: belongsTo seller


--~--~-~--~~~---~--~~
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: Cakephp 1.2 + swfupload

2009-06-24 Thread Bryan Paddock
hey man
thanks for the heads up... tried searching through there again.. still no
luck...

It's a weird problem.. swfupload appears to be working 99%... I get the file
upload box, I can upload a file and it displayed the progress etc as the
file gets uploaded... but theres just no data appearing at the other side in
the controller function... no matter how big/small the file is...

Has nobody else experienced this problem?


On Fri, Jun 19, 2009 at 10:06 PM, rod rodrigo.z...@gmail.com wrote:


 I'm sure you can find something on this group:

 http://groups.google.com/group/cake-php/search?group=cake-phpq=swfuploadqt_g=Search+this+group
 or at swfupload website: http://swfupload.org/search/node/cakeph

 I've been using a similar one, Uploadify: www.uploadify.com

 On Jun 18, 1:38 pm, Bryan Paddock bryanpadd...@gmail.com wrote:
  Hey guys,
  I've been sitting with this swfupload module for days and just cant seem
 to
  get it right.
 
  In my js to create the uploader i have this setting:
 
  upload_url: /properties/uploadvideo,
 
  and I have my function uploadvideo() in my properties controller
 
  I've done some simple debugging like so:
 
  $fp = fopen('/tmp/debug', 'w');
  fwrite($fp, print_r($this-params['form'], true));
  fclose($fp);
 
  swfupload successfully sends the file to the server althought all that
 finds
  its way to the debug file is array()
 
  cakephp is not handling the file upload...
 
  any ideas? has anyone here got it working successfully?
 
  bryan
 


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Pagination not respecting page numbers

2009-06-24 Thread Bryan Paddock

Hey all,

I was using the paginator and it was working pretty well for me when I
was using all the search criteria as named url parameters. I
discovered that the paginator didn't send the parameters to the next
pages so implemented sessions to store the criteria.

The arrays I create from the session (critera/order) generate fine and
the page number variable I take from the named url parameter.

examples of values follow

$conditions = Array
(
[sale] = 1
)


$theorder = Array
(
[created_date_time] = DESC
)

$resultsperpage = 10;

$page = 1; // or 2, 3, etc

My paginator call is:

$data = $this-paginate('Property', $conditions, $theorder,
$resultsperpage, $page);

For some reason it respects the conditions, order and results per page
but NOT the page number. Anyone have any ideas why? I test the value
of the $page variable and it does correctly change but the data
received from the model remains the same.

Am I doing something wrong here? I can't figure out what's going on

thanks!
bryan

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Cakephp 1.2 + swfupload

2009-06-18 Thread Bryan Paddock
Hey guys,
I've been sitting with this swfupload module for days and just cant seem to
get it right.

In my js to create the uploader i have this setting:

upload_url: /properties/uploadvideo,

and I have my function uploadvideo() in my properties controller

I've done some simple debugging like so:

$fp = fopen('/tmp/debug', 'w');
fwrite($fp, print_r($this-params['form'], true));
fclose($fp);

swfupload successfully sends the file to the server althought all that finds
its way to the debug file is array()

cakephp is not handling the file upload...

any ideas? has anyone here got it working successfully?

bryan

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Accessing auth information from within model class

2009-06-08 Thread Bryan Paddock
Hey all,
I can't seem to find out how to access the Auth class from within the model?

I have models/property.php where in the afterfind() function I need to
perform certain functions based on the user_id if the user is logged in.

$this-Auth-user() is not within the scope.

I can't use $this-Session either.

Any ideas on how I can access either of them?

thanks!

Bryan

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



hooking onto the find() query

2009-06-01 Thread Bryan Paddock
hey guys,
is it possible to hook onto the database queries?

ie: each time i call a $this-Property-find() or findById() etc etc I would
like to perform certain functions on the data returned and include them in
the results..

I know I can create my own function for pulling data out but I was hoping
there was a way to do it without creating too many of my own functions...

bryan

--~--~-~--~~~---~--~~
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: hooking onto the find() query

2009-06-01 Thread Bryan Paddock
*shoots himself for not seeing that...
thanks man...

On Mon, Jun 1, 2009 at 6:33 PM, Eber Freitas Dias eber.frei...@gmail.comwrote:

 I guess this is what you need:

 http://book.cakephp.org/view/76/Callback-Methods


 On Mon, Jun 1, 2009 at 1:30 PM, Bryan Paddock bryanpadd...@gmail.comwrote:

 hey guys,
 is it possible to hook onto the database queries?

 ie: each time i call a $this-Property-find() or findById() etc etc I
 would like to perform certain functions on the data returned and include
 them in the results..

 I know I can create my own function for pulling data out but I was hoping
 there was a way to do it without creating too many of my own functions...

 bryan







 --
 Éber Freitas Dias

 www.eberfdias.com
 www.dejamps.net

 


--~--~-~--~~~---~--~~
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: Need help on password generation

2009-05-27 Thread Bryan Paddock
Hi Gangzheng,
Use the core ajax helper for that.

in your controller:

var $helpers = array('Ajax', 'Javascript')
var $components = array('RequestHandler')

in the view that is going to hold the link, create the link with the ajax
helper instead of the html helper:

echo $ajax-link( 'Generate Password',
array( 'controller' = 'controllername', 'action' =
'generatePassword',
array( 'update' = 'id_of_div_to_be_updated', 'complete' = 'alert(Your
password has been generated) ' ) );

then in your generatepassword controller function make sure you send the
generated password to the view which you'll create in your views/controller
folder

$this-set('password', $new_password);

so you can print out the password in your view with

echo $password;

hope this helps!

bryan


On Wed, May 27, 2009 at 8:39 AM, liaogz82 liaog...@gmail.com wrote:


 Hi all,

 I need help on the cakePHP coding. I have a function called
 generatePassword() in the controller. I want to create an ajax link in
 such a way that user can click on the link and it will talk to the
 method, take the password and display it on the textbox. Can this be
 done?

 Gangzheng
 


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



geo-location database

2009-05-27 Thread Bryan Paddock
hey guys,
not really a cake specific question but related nonetheless...

have any of you worked with international location databases? know of any
pay-for or free?

busy working on a property site and the requirement is to have it be
internationalized with country-state/suburb/county/etc selectable for the
whole world... it's quite a requirement but it must have been done before...

--~--~-~--~~~---~--~~
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 redirect to login page

2009-05-26 Thread Bryan Paddock
Hi Bharani,
Read through the cakephp cookbook http://book.cakephp.org

More specifically the section on auth:
http://book.cakephp.org/view/172/Authentication

Pointers: http://book.cakephp.org/view/172/Authentication
 - set up the Auth component in your app_controller and add setup settings
in the beforeFilter() function
 - set which pages you are allowed anonymous access to using
$this-Auth-allow('index', 'posts', 'etc', 'etc); (in beforeFilter())
 - add login() and logout() functions to your controller(s) you wish to do
auth...

the cookbook has rather detailed explanations

bryan

On Tue, May 26, 2009 at 11:11 AM, lakers fan lakersfa...@msn.com wrote:

  Hello,
  I m new to cakephp.. I want to check in every page whether a user has
 logged in or not.. If not I want to redirect him to login page. Is there a
 way to do it in a common place like app_controller?

 Thanks,
 Bharani

 --
 Windows Live™: Keep your life in sync. Check it 
 out.http://windowslive.com/explore?ocid=TXT_TAGLM_BR_life_in_synch_052009
 


--~--~-~--~~~---~--~~
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: Problem with retrieving data with relationships

2009-05-25 Thread Bryan Paddock
ahhh awesome thanks man... still getting to grips with cakephp here!


On Sat, May 23, 2009 at 8:45 PM, Ricky Paz ricky...@gmail.com wrote:


 Hi,

 You have to use belongsTo and hasMany for 1-n relationship, and not
 hasOne and hasMany. In your PropertiesModel, put $belongsTo =
 'Seller, and, inside SellerModel, put hasMany = 'Property'.
 


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Problem with retrieving data with relationships

2009-05-22 Thread Bryan Paddock
Hi all,
Just started learning cakephp last week so a bit scratchy and still
learning...

There are two tables in question here:

property - stores rows of properties
seller - stores sellers of the properties.

- one property can only have one seller
- one seller can have many properties

property model has its hasone definition:

  // one property has one seller
  var $hasOne = array(
'Seller' = array(
  'className'= 'Seller',
  'foreignKey'= 'id'
)
  );

seller model has its hasmany defintion:

  // one seller can have any number of favourites and properties
  var $hasMany = array(
'Favourite' = array(
  'className' = 'Favourite',
  'foreignKey'= 'seller_id',
  'dependent'= true
),
'Property' = array(
  'className' = 'Property',
  'foreignKey' = 'seller_id'
)
  );

ignore the favourites table for now...

property table contains 'seller_id'

property table

id
seller_id
x

seller table
---
id
xx

(I do have $useTable defined in each model to ensure table names are
correct)

In my browse function of the propertiescontroller I have the standard code:

$this-pageTitle = 'Browse All Properties';
$this-paginate['limit'] = 25;
$data = $this-paginate('Property');
$this-set('properties', $data);

It returns the properties but blank seller information.. it has the full
seller array with all the database fields but no values for any of them...

Can anyone shed some light on this?

I'm quite stuck here!

- Bryan

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---