Re: session is not working between different actions on different controllers

2010-08-01 Thread Kei Simone
Hi all,

thanks for all your responses.

i think perhaps my situation was worded a bit wrongly. hence most
responses seem to be saying i am trying to access session variables of
1 cake app from another.

actually, i should emphasize that when i said the carts/add will set a
session value, this refers to

the cake app localhost/checkout 's carts/add setting a session
variable for its own app. ie localhost/checkout.

subsequently in the SAME app a different controller/action ie orders/
pay will attempt to read the session variable. which curiously is no
longer existing.

anyway, i resolved the whole situation by ironically enough, using
database for SESSION and then passing the session variable from 1 app
to another via the database

it was more sophisticated than what i was originally trying to do ,
but hey, that is life right? i am sure even excellent google apps have
1 or 2 workarounds. :)

Thank you all for your answers.

If anyone is able to point out to me why the original way cannot work,
or make the original way work, i will be greatly grateful.

On Aug 1, 1:58 pm, Dr. Loboto drlob...@gmail.com wrote:
 PLUS there is need to pass session ID via URL. As cookies works ONLY
 for one domain.

 On Jul 31, 3:52 am, Beavis de Milo wig...@gmail.com wrote:



  DragonFlyEye - Isn't what Kei is attempting possible using database
  sessions?  He could store the DB session in the default database and
  each seperate app could have it's own private DB for data.

  On Jul 30, 12:25 pm, DragonFlyEye dragonflyey...@gmail.com wrote:

   Well, you're not going to be able to maintain a standard session
   across multiple domains. That's basic to sessions and cookies. You can
   certainly create some sort of non-visible login system (like a GET
   variable) that allows the user to see the same things on two domains,
   but a literal session across two domains is definitely not going to
   work.

   This is less about CakePHP and more about sessions and cookies as a
   broad subject, not really fit for this list. I suggest you do a bit of
   research on the topic before getting in too deep.

   On Jul 30, 11:15 am, Kei Simone kimc...@gmail.com wrote:

Hi there,

the idea is that i am doing something like an ecommerce platform for
merchants.

there are 2 apps because i want the shopping site to be on 1 domain
and the checkout pages to be on another domain.

so that i can use ssl on the checkout pages and that this is
consistent for ALL customers who buy stuff from different merchants.

 1. Localhost can often be a tricky thing for cookies and sessions.
 Make sure those addresses are really the way content is being served
 up to the browser.

i dont quite get this point. what do you mean by make sure the
addresses are really the way content is being served?

 2. Cookie settings in Configure::write(): make sure they're set for
 the exact same location, not /checkout and /wp

i am just confused about this suggestion.

On Jul 30, 10:58 pm, DragonFlyEye dragonflyey...@gmail.com wrote:

 Why two separate applications for this? Is one not CakePHP?

 Offhand, here's a few things:
 1. Localhost can often be a tricky thing for cookies and sessions.
 Make sure those addresses are really the way content is being served
 up to the browser.
 2. Cookie settings in Configure::write(): make sure they're set for
 the exact same location, not /checkout and /wp

 On Jul 30, 10:48 am, Kei Simone kimc...@gmail.com wrote:

  Hi all,

  i have 2 cake apps. localhost/wp and localhost/checkout. wp sends a
  httpsocket-post to localhost/checkout/carts/add and gets a result.
  the carts/add will set a session value. wp will use the result of 
  the
  post and redirects to paypalsandbox. after that the paypalsandbox 
  will
  redirect to localhost/checkout/orders/pay. however in orders/pay it
  cannot find the session written in carts/add

 http://picasaweb.google.com/lh/photo/o_Ylvp3uqtQer-d5HC9Lgg?feat=dire...
  describes my situation

  i have tried setting security to low

  changing to database for my session

  changing to custom handler where the referer_check is empty string

  change session cookiename

  change checkAgent to false

  so if you have any other methods, please please tell me.

  i am really stuck.

  i am not sure if this is due to the paypal page redirecting? or due 
  to
  the fact that the place where i first write the session value i am
  used a httpsocket post.

  Please advise. thank you.

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

session is not working between different actions on different controllers

2010-07-30 Thread Kei Simone
Hi all,

i have 2 cake apps. localhost/wp and localhost/checkout. wp sends a
httpsocket-post to localhost/checkout/carts/add and gets a result.
the carts/add will set a session value. wp will use the result of the
post and redirects to paypalsandbox. after that the paypalsandbox will
redirect to localhost/checkout/orders/pay. however in orders/pay it
cannot find the session written in carts/add

http://picasaweb.google.com/lh/photo/o_Ylvp3uqtQer-d5HC9Lgg?feat=directlink
describes my situation

i have tried setting security to low

changing to database for my session

changing to custom handler where the referer_check is empty string

change session cookiename

change checkAgent to false

so if you have any other methods, please please tell me.

i am really stuck.

i am not sure if this is due to the paypal page redirecting? or due to
the fact that the place where i first write the session value i am
used a httpsocket post.

Please advise. thank you.

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: session is not working between different actions on different controllers

2010-07-30 Thread Kei Simone
Hi there,

the idea is that i am doing something like an ecommerce platform for
merchants.

there are 2 apps because i want the shopping site to be on 1 domain
and the checkout pages to be on another domain.

so that i can use ssl on the checkout pages and that this is
consistent for ALL customers who buy stuff from different merchants.

 1. Localhost can often be a tricky thing for cookies and sessions.
 Make sure those addresses are really the way content is being served
 up to the browser.

i dont quite get this point. what do you mean by make sure the
addresses are really the way content is being served?

 2. Cookie settings in Configure::write(): make sure they're set for
 the exact same location, not /checkout and /wp

i am just confused about this suggestion.


On Jul 30, 10:58 pm, DragonFlyEye dragonflyey...@gmail.com wrote:
 Why two separate applications for this? Is one not CakePHP?

 Offhand, here's a few things:
 1. Localhost can often be a tricky thing for cookies and sessions.
 Make sure those addresses are really the way content is being served
 up to the browser.
 2. Cookie settings in Configure::write(): make sure they're set for
 the exact same location, not /checkout and /wp

 On Jul 30, 10:48 am, Kei Simone kimc...@gmail.com wrote:



  Hi all,

  i have 2 cake apps. localhost/wp and localhost/checkout. wp sends a
  httpsocket-post to localhost/checkout/carts/add and gets a result.
  the carts/add will set a session value. wp will use the result of the
  post and redirects to paypalsandbox. after that the paypalsandbox will
  redirect to localhost/checkout/orders/pay. however in orders/pay it
  cannot find the session written in carts/add

 http://picasaweb.google.com/lh/photo/o_Ylvp3uqtQer-d5HC9Lgg?feat=dire...
  describes my situation

  i have tried setting security to low

  changing to database for my session

  changing to custom handler where the referer_check is empty string

  change session cookiename

  change checkAgent to false

  so if you have any other methods, please please tell me.

  i am really stuck.

  i am not sure if this is due to the paypal page redirecting? or due to
  the fact that the place where i first write the session value i am
  used a httpsocket post.

  Please advise. thank you.

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


how to activate child afterDelete callbacks when i delete parent model?

2010-06-02 Thread Kei Simone
hi,

i have a parent model that hasMany child models.

when the child model is deleted, i need to delete the images
associated with the child model.

hence i want to place it in the afterDelete callback of the child
model.

now the association of parent with child is like this:

var $hasMany = array(
'Child' = array(
'className' = 'Child',
'foreignKey' = 'parent_id',
'dependent' = true,
'conditions' = '',
'fields' = '',
'order' = '',
'limit' = '',
'offset' = '',
'exclusive' = true,
'finderQuery' = '',
'counterQuery' = ''
),

);

how do i activate the child afterDelete when i delete parent?

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


how to write a test case for a behavior when my TestCaseModel $useTable must always be false?

2010-05-17 Thread Kei Simone
Hi

i wrote a plugin that has just a behavior inside.

and i want to write a test case for that plugin.

i need to test if the data array of the model that is attached to the
behavior is changed
because i call a particular function in the  behavior.

however that function will only change the data array ONLY if the
useTable variable of the model is NOT false.

Now here comes the problem.

The Model Class i wrote inside the same test case file extends
TestCaseModel but it has useTable set as false. and if i try to set to
anything. i will get error about missing datatable.


Please advise.

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: PHP CodeSniffer

2010-05-15 Thread Kei Simone
I second this. though i found the github code for code_check and
autotest. i think having 1 for Php_codesniffer would be a very good
idea to increase cake usage as well.

Braindead wrote:
 Hi Achilleas,

 you are right that CodeSniffer validates your code to make sure that
 it follows certain conventions. It is possible to define a validation
 set that reflects CakePHPs conventions. If your code doesn't follow
 these conventions CodeSniffer gives you a warning and you have the
 possibility to correct it (if you want to).

 As I'm new to CodeSniffer I thought that there must be someone who
 already uses CodeSniffer with CakePHP and who is willing to share his
 validation set with me (and anyone else ho is interested). I wonder
 how the CakePHP core developers validate for conventions?

 Thanks,
 Markus

 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.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Kei Simone
Is the bindModel any better than the joins?

http://book.cakephp.org/view/1047/Joining-tables

the joins are working for me. however of course the reason why i am
asking so many quesitons is to increase my working knowledge of Cake
for what works and what does not.

thank you.

On May 3, 3:52 pm, AD7six andydawso...@gmail.com wrote:
 On May 3, 7:02 am, Kei Simone kimc...@gmail.com wrote:





  Hi i did this

  $this-Behaviors-attach('Containable');
                  $this-User-Behaviors-attach('Containable');
                  $this-Shop-Behaviors-attach('Containable');
                  $this-Shop-Domain-Behaviors-attach('Containable');

                  $this-recursive = -1;
                  $this-User-recursive = -1;
                  $this-Shop-recursive = -1;
                  $this-Shop-Domain-recursive = -1;

                  return $this-find('first', array(
                          // conditions for the main model
                          'conditions'=array('Merchant.owner'=1),
                          // contain
                          'contain'=array(
                                  'User'=array(
                                          // conditions for the user model
                                          
  'conditions'=array('User.group_id'=MERCHANTS,
                                                              'User.email' = 
  'a...@a.com',),

                                  ),
                                  'Shop'=array(
                                          
  'conditions'=array('Shop.web_address' = 'http://
  abc.myspree2shop.com',),
                                                'Domain'),
                          )
                  ));

  i got this in the sql query log

  SELECT `Merchant`.`id`, `Merchant`.`owner`, `Merchant`.`shop_id`,
  `Merchant`.`user_id`, `Shop`.`id`, `Shop`.`theme_id`, `Shop`.`name`,
  `Shop`.`web_address`, `Shop`.`created_on`, `Shop`.`modified_on`,
  `Shop`.`status`, `User`.`id`, `User`.`email`, `User`.`password`,
  `User`.`group_id`, `User`.`full_name`, `User`.`name_to_call`,
  `User`.`last_login_on`, `User`.`status`, `User`.`created_on`,
  `User`.`modified_on` FROM `merchants` AS `Merchant` LEFT JOIN `shops`
  AS `Shop` ON (`Merchant`.`shop_id` = `Shop`.`id` AND
  `Shop`.`web_address` = 'http://abc.myspree2shop.com') LEFT JOIN
  `users` AS `User` ON (`Merchant`.`user_id` = `User`.`id` AND
  `User`.`group_id` = 3 AND `User`.`email` = 'a...@a.com') WHERE
  `Merchant`.`owner` = 1 LIMIT 1

  SELECT `Shop`.`id`, `Shop`.`theme_id`, `Shop`.`name`,
  `Shop`.`web_address`, `Shop`.`created_on`, `Shop`.`modified_on`,
  `Shop`.`status` FROM `shops` AS `Shop` WHERE `Shop`.`id` = 1 AND
  `Shop`.`web_address` = 'http://abc.myspree2shop.com'

  SELECT `User`.`id`, `User`.`email`, `User`.`password`,
  `User`.`group_id`, `User`.`full_name`, `User`.`name_to_call`,
  `User`.`last_login_on`, `User`.`status`, `User`.`created_on`,
  `User`.`modified_on` FROM `users` AS `User` WHERE `User`.`id` = 1 AND
  `User`.`group_id` = 3 AND `User`.`email` = 'a...@a.com'

  i got this result

  Array
  (
      [Merchant] = Array
          (
              [id] = 1
              [owner] = 1
              [shop_id] = 1
              [user_id] = 1
          )

      [Shop] = Array
          (
              [id] =
              [theme_id] =
              [name] =
              [web_address] =
              [created_on] =
              [modified_on] =
              [status] =
          )

      [User] = Array
          (
              [id] =
              [email] =
              [password] =
              [group_id] =
              [full_name] =
              [name_to_call] =
              [last_login_on] =
              [status] =
              [created_on] =
              [modified_on] =
          )

  )

  When i changed your recommendation to

                              return $this-find('first',
                                          array(
                                            'contain'=array(
                                                             'User',
                                                             'Shop' = 
  array('Domain'
                                                                          ),

                                                             ),
                                            'conditions' = 
  array('User.group_id'=MERCHANTS,
                                                              'User.email' = 
  'a...@a.com',

  'Shop.web_address' = 'http://abc.myspree2shop.com',
                                                             )
                                            )
                                  );

  all i did was to move all the conditions to the main model.

  i got this in my sql query log:
  SELECT `Merchant`.`id`, `Merchant`.`owner`, `Merchant`.`shop_id`,
  `Merchant`.`user_id`, `Shop`.`id`, `Shop`.`theme_id`, `Shop`.`name`,
  `Shop`.`web_address`, `Shop`.`created_on`, `Shop

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Kei Simone
I dont like recursive because i suspect that it will return all the
related model data of a certain level.

i only want very specific model data. or rather data from specific
models.


On May 3, 3:35 pm, Andrei Mita andrei.m...@gmail.com wrote:
 Or here is another idea. Make a find('all') query with $recursive = 2 and
 see how much information is there that you don't need.



 On Mon, May 3, 2010 at 10:33 AM, Andrei Mita andrei.m...@gmail.com wrote:
  Simone,

  Containable is extremely powerful. I am just amazed how little time it
  takes me to write complex queries.

  Give me the structure of the tables and an example of what do you want to
  retrieve from them and I might be able to help you around.

  On Mon, May 3, 2010 at 8:02 AM, Kei Simone kimc...@gmail.com wrote:

  Hi i did this

  $this-Behaviors-attach('Containable');
                 $this-User-Behaviors-attach('Containable');
                 $this-Shop-Behaviors-attach('Containable');
                 $this-Shop-Domain-Behaviors-attach('Containable');

                 $this-recursive = -1;
                 $this-User-recursive = -1;
                 $this-Shop-recursive = -1;
                 $this-Shop-Domain-recursive = -1;

                 return $this-find('first', array(
                          // conditions for the main model
                          'conditions'=array('Merchant.owner'=1),
                          // contain
                         'contain'=array(
                                 'User'=array(
                                         // conditions for the user model

   'conditions'=array('User.group_id'=MERCHANTS,
                                                             'User.email' =
  'a...@a.com',),

                                 ),
                                 'Shop'=array(

   'conditions'=array('Shop.web_address' = 'http://
  abc.myspree2shop.com',),
                                               'Domain'),
                         )
                 ));

  i got this in the sql query log

  SELECT `Merchant`.`id`, `Merchant`.`owner`, `Merchant`.`shop_id`,
  `Merchant`.`user_id`, `Shop`.`id`, `Shop`.`theme_id`, `Shop`.`name`,
  `Shop`.`web_address`, `Shop`.`created_on`, `Shop`.`modified_on`,
  `Shop`.`status`, `User`.`id`, `User`.`email`, `User`.`password`,
  `User`.`group_id`, `User`.`full_name`, `User`.`name_to_call`,
  `User`.`last_login_on`, `User`.`status`, `User`.`created_on`,
  `User`.`modified_on` FROM `merchants` AS `Merchant` LEFT JOIN `shops`
  AS `Shop` ON (`Merchant`.`shop_id` = `Shop`.`id` AND
  `Shop`.`web_address` = 'http://abc.myspree2shop.com') LEFT JOIN
  `users` AS `User` ON (`Merchant`.`user_id` = `User`.`id` AND
  `User`.`group_id` = 3 AND `User`.`email` = 'a...@a.com') WHERE
  `Merchant`.`owner` = 1 LIMIT 1

  SELECT `Shop`.`id`, `Shop`.`theme_id`, `Shop`.`name`,
  `Shop`.`web_address`, `Shop`.`created_on`, `Shop`.`modified_on`,
  `Shop`.`status` FROM `shops` AS `Shop` WHERE `Shop`.`id` = 1 AND
  `Shop`.`web_address` = 'http://abc.myspree2shop.com'

  SELECT `User`.`id`, `User`.`email`, `User`.`password`,
  `User`.`group_id`, `User`.`full_name`, `User`.`name_to_call`,
  `User`.`last_login_on`, `User`.`status`, `User`.`created_on`,
  `User`.`modified_on` FROM `users` AS `User` WHERE `User`.`id` = 1 AND
  `User`.`group_id` = 3 AND `User`.`email` = 'a...@a.com'

  i got this result

  Array
  (
     [Merchant] = Array
         (
             [id] = 1
             [owner] = 1
             [shop_id] = 1
             [user_id] = 1
         )

     [Shop] = Array
         (
             [id] =
             [theme_id] =
             [name] =
             [web_address] =
             [created_on] =
             [modified_on] =
             [status] =
         )

     [User] = Array
         (
             [id] =
             [email] =
             [password] =
             [group_id] =
             [full_name] =
             [name_to_call] =
             [last_login_on] =
             [status] =
             [created_on] =
             [modified_on] =
         )

  )

  When i changed your recommendation to

                             return $this-find('first',
                                         array(
                                           'contain'=array(
                                                            'User',
                                                            'Shop' =
  array('Domain'
                                                                         ),

                                                            ),
                                            'conditions' =
  array('User.group_id'=MERCHANTS,
                                                             'User.email' =
  'a...@a.com',

  'Shop.web_address' = 'http://abc.myspree2shop.com',
                                                            )
                                           )
                                 );

  all i did was to move all the conditions

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Kei Simone
Your statement on the right join i do not quite understand.

Which find statement are you explaining on?

Thank you for being enthusiastic to clear my doubts.


On May 3, 3:55 pm, AD7six andydawso...@gmail.com wrote:
 On May 2, 1:45 pm, Jon Bennett jmbenn...@gmail.com wrote:





   i need to use Merchant model to do a find of all 4 related data.
   notice that Domain is the only one NOT directly related to Merchant.

   i tried this in a method inside Merchant model:

   $this-Behaviors-attach('Containable');
   $this-User-Behaviors-attach('Containable');
   $this-Shop-Behaviors-attach('Containable');
   $this-Shop-Domain-Behaviors-attach('Containable');

   $this-recursive = -1;
   $this-User-recursive = -1;
   $this-Shop-recursive = -1;
   $this-Shop-Domain-recursive = -1;

   return $this-find('first',
                  array(
                    'contain'=array(
                                           'User',
                                           'Shop' = array('Domain' ),

                                          ),
                  'conditions' = $conditions
          ));

  http://book.cakephp.org/view/1323/Containablehaserrors in terms of
   telling you where to place the conditions. my way is correct as of 1.3
   Cakephp

  return $this-find('first', array(
          // conditions for the main model
          'conditions'=array(),
          // contain
          'contain'=array(
                  'User'=array(
                          // conditions for the user model
                          'conditions'=array('User.status'=1),
                          'Other', 'Models', 'From', 'User'
                  ),
                  'Shop'=array('Domain'),
          )
  ));

 Using conditions like that is the equivalent of a right join - you're
 still going to get every single main model row - and just get an
 empty array for any row which links to a user with a status that isn't
 1.

 hth,

 AD

 Check out the new CakePHP Questions sitehttp://cakeqs.organd 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 
 athttp://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: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Kei Simone
Hi Andy,

1) it is precisely i have tried it see my ultra long post with all the
sql queries and result sets that i know containable is not for me.

i am still looking to see if your linkable behavior is what i need.

however, i am quite noob, so i dont know how to use your one_query
even though i have copied it and pasted it in my behavior folder.

I am a 1 month cake user so please be gentle.

Is there a more complete guide to show me how to use it? ideally would
be if you can provide an example using my scenario above.

if it is better than the joins i am doing, then i am definitely going
to use it greatly because i foresee i am going to use a lot of complex
searches.

my schema once again is

User hasOne Merchant (so Merchant belongsTo User with user_id inside
merchants table)
Shop hasMany Merchant (so Merchant belongsTo Shop with shop_id inside
merchants table)
Shop hasMany Domain (so Domain belongsTo Shop with shop_id inside
domains table)

i am trying to get the first datarow that meets conditions for User,
Domain and the datarow must draw data from all 4 models.

Really looking to hear more from you. Your one_query or linkable
behavior sounds like a lot better than the run of the mill answers i
get from the irc channel.

2) though i have some concerns about the maintainence of your
behavior. looks like you do not have many watchers or people raising
issues.

NO offence.

It is just that i have tried out a few plugins thinking that they
would speed up my work. end up i wasted more time getting them to
work.

the only plugin i am using now is MeioUpload it has promised to a
certain extent is the MeioUpload and the owner is actively answering
issues which is many and that there are plenty of watchers. In fact i
reported 3 issues with suggestions to fix 2 of those 3 issues. the
fixes are adopted by MeioUpload owner hence i am quite happy to
continue to use it. So i am now biased towards code that has owner
actively answering issues and many active users.

Once again, i have nothing against your code. i highly appreciate your
suggestion. and i definitely would want to learn more and definitely
use it if i find it superior to using joins.

Already i can see that it looks more promising than Containable based
on the blogpost link you sent.

So do give me a heads up in terms of using it especially since the
blogpost contains information about using Linkable where as your code
is called one_query.

On May 4, 4:31 pm, AD7six andydawso...@gmail.com wrote:
 On May 4, 9:45 am, Kei Simone kimc...@gmail.com wrote:

  Your statement on the right join i do not quite understand.

  Which find statement are you explaining on?

  Thank you for being enthusiastic to clear my doubts.

 Kei - you don't need to reply to each question individually - you can
 reply to many messages in the same reply ;)

 bindModel - if you bind a belongsTo or hasOne - is a join. so there is
 no advantage except it's a lot easier to say:

 $this-bindModel(array('hasOne' = array('OtherModel' = array(...));
 return $this-find(...);
 than
 return $this-find($type, $arraywithjoins);

 but it depends how explicit you want to be.

 Regarding Your statement on right joins

 These are not equivalent:

 return $this-find('all', array(
                   'contain'=array(
                                          'Shop' = array('Domain'  =
 array('conditions' = $someconditions)),
                                         ),
         ));

 return $this-find('all', array(
                   'contain'=array(
                                          'Shop' = array('Domain')),
                                         ),
                  'conditions' = $someconditions
         ));

 Let's say
  $this is users and you've got 10k.
  $someconditions = array('Domain.id' = 42)
  you're expecting one result - the user linked via shop to the domain
 42.

 The first query will return you 10k rows, and the domain data will be
 empty/missing for 9,999 rows - because cake builds the data using
 multiple queries and the first query has no conditions.

 The second query will return you 1 row - if you explicitly used joins
 or used one of the behaviors I mentioned that means you get what you
 asked for.

 If you're still in doubt - try it.

 hth,

 AD

 $this-







  On May 3, 3:55 pm, AD7six andydawso...@gmail.com wrote:

   On May 2, 1:45 pm, Jon Bennett jmbenn...@gmail.com wrote:

 i need to use Merchant model to do a find of all 4 related data.
 notice that Domain is the only one NOT directly related to Merchant.

 i tried this in a method inside Merchant model:

 $this-Behaviors-attach('Containable');
 $this-User-Behaviors-attach('Containable');
 $this-Shop-Behaviors-attach('Containable');
 $this-Shop-Domain-Behaviors-attach('Containable');

 $this-recursive = -1;
 $this-User-recursive = -1;
 $this-Shop-recursive = -1;
 $this-Shop-Domain-recursive = -1;

 return $this-find('first',
                array

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Kei Simone
i have the following for my cake 1.3:

User hasOne Merchant (so Merchant belongsTo User)
Shop hasMany Merchant (so Merchant belongsTo Shop as well.)
Shop hasMany Domain (so Domain belongsTo Shop.)

i need to use Merchant model to do a find of all 4 related data.

i need to find the first datarow that matches conditions for Merchant,
User and Domain.

Merchant.owner = 1
User.email = a...@a.com
Domain.domain = http://abc.example.com
Domain.primary = 1


the datarow must contain data from all 4 models.

the find must be done inside the Merchant model. as in $this-find...

Love to hear more from you about Containable. Really interested to see
how powerful Containable is.


On May 3, 3:33 pm, Andrei Mita andrei.m...@gmail.com wrote:
 Simone,

 Containable is extremely powerful. I am just amazed how little time it takes
 me to write complex queries.

 Give me the structure of the tables and an example of what do you want to
 retrieve from them and I might be able to help you around.



 On Mon, May 3, 2010 at 8:02 AM, Kei Simone kimc...@gmail.com wrote:
  Hi i did this

  $this-Behaviors-attach('Containable');
                 $this-User-Behaviors-attach('Containable');
                 $this-Shop-Behaviors-attach('Containable');
                 $this-Shop-Domain-Behaviors-attach('Containable');

                 $this-recursive = -1;
                 $this-User-recursive = -1;
                 $this-Shop-recursive = -1;
                 $this-Shop-Domain-recursive = -1;

                 return $this-find('first', array(
                          // conditions for the main model
                          'conditions'=array('Merchant.owner'=1),
                          // contain
                         'contain'=array(
                                 'User'=array(
                                         // conditions for the user model

   'conditions'=array('User.group_id'=MERCHANTS,
                                                             'User.email' =
  'a...@a.com',),

                                 ),
                                 'Shop'=array(

   'conditions'=array('Shop.web_address' = 'http://
  abc.myspree2shop.com',),
                                               'Domain'),
                         )
                 ));

  i got this in the sql query log

  SELECT `Merchant`.`id`, `Merchant`.`owner`, `Merchant`.`shop_id`,
  `Merchant`.`user_id`, `Shop`.`id`, `Shop`.`theme_id`, `Shop`.`name`,
  `Shop`.`web_address`, `Shop`.`created_on`, `Shop`.`modified_on`,
  `Shop`.`status`, `User`.`id`, `User`.`email`, `User`.`password`,
  `User`.`group_id`, `User`.`full_name`, `User`.`name_to_call`,
  `User`.`last_login_on`, `User`.`status`, `User`.`created_on`,
  `User`.`modified_on` FROM `merchants` AS `Merchant` LEFT JOIN `shops`
  AS `Shop` ON (`Merchant`.`shop_id` = `Shop`.`id` AND
  `Shop`.`web_address` = 'http://abc.myspree2shop.com') LEFT JOIN
  `users` AS `User` ON (`Merchant`.`user_id` = `User`.`id` AND
  `User`.`group_id` = 3 AND `User`.`email` = 'a...@a.com') WHERE
  `Merchant`.`owner` = 1 LIMIT 1

  SELECT `Shop`.`id`, `Shop`.`theme_id`, `Shop`.`name`,
  `Shop`.`web_address`, `Shop`.`created_on`, `Shop`.`modified_on`,
  `Shop`.`status` FROM `shops` AS `Shop` WHERE `Shop`.`id` = 1 AND
  `Shop`.`web_address` = 'http://abc.myspree2shop.com'

  SELECT `User`.`id`, `User`.`email`, `User`.`password`,
  `User`.`group_id`, `User`.`full_name`, `User`.`name_to_call`,
  `User`.`last_login_on`, `User`.`status`, `User`.`created_on`,
  `User`.`modified_on` FROM `users` AS `User` WHERE `User`.`id` = 1 AND
  `User`.`group_id` = 3 AND `User`.`email` = 'a...@a.com'

  i got this result

  Array
  (
     [Merchant] = Array
         (
             [id] = 1
             [owner] = 1
             [shop_id] = 1
             [user_id] = 1
         )

     [Shop] = Array
         (
             [id] =
             [theme_id] =
             [name] =
             [web_address] =
             [created_on] =
             [modified_on] =
             [status] =
         )

     [User] = Array
         (
             [id] =
             [email] =
             [password] =
             [group_id] =
             [full_name] =
             [name_to_call] =
             [last_login_on] =
             [status] =
             [created_on] =
             [modified_on] =
         )

  )

  When i changed your recommendation to

                             return $this-find('first',
                                         array(
                                           'contain'=array(
                                                            'User',
                                                            'Shop' =
  array('Domain'
                                                                         ),

                                                            ),
                                            'conditions' =
  array('User.group_id'=MERCHANTS

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Kei Simone
Sorry for the continuous replies.

Just realised that my scenario was not complete enough.

User hasOne Merchant (so Merchant belongsTo User and user_id inside
merchants table)
Shop hasMany Merchant (so Merchant belongsTo Shop and shop_id inside
merchants table)
Shop hasMany Domain (so Domain belongsTo Shop and shop_id inside
domains table)

i need to use Merchant model to do a find of all 4 related data.

i need to find the first datarow that matches conditions for Merchant,
User and Domain.

Merchant.owner = 1
User.email = a...@a.com
Domain.domain = http://abc.example.com
Domain.primary = 1


the datarow must contain data from all 4 models.


On May 4, 4:31 pm, AD7six andydawso...@gmail.com wrote:
 On May 4, 9:45 am, Kei Simone kimc...@gmail.com wrote:

  Your statement on the right join i do not quite understand.

  Which find statement are you explaining on?

  Thank you for being enthusiastic to clear my doubts.

 Kei - you don't need to reply to each question individually - you can
 reply to many messages in the same reply ;)

 bindModel - if you bind a belongsTo or hasOne - is a join. so there is
 no advantage except it's a lot easier to say:

 $this-bindModel(array('hasOne' = array('OtherModel' = array(...));
 return $this-find(...);
 than
 return $this-find($type, $arraywithjoins);

 but it depends how explicit you want to be.

 Regarding Your statement on right joins

 These are not equivalent:

 return $this-find('all', array(
                   'contain'=array(
                                          'Shop' = array('Domain'  =
 array('conditions' = $someconditions)),
                                         ),
         ));

 return $this-find('all', array(
                   'contain'=array(
                                          'Shop' = array('Domain')),
                                         ),
                  'conditions' = $someconditions
         ));

 Let's say
  $this is users and you've got 10k.
  $someconditions = array('Domain.id' = 42)
  you're expecting one result - the user linked via shop to the domain
 42.

 The first query will return you 10k rows, and the domain data will be
 empty/missing for 9,999 rows - because cake builds the data using
 multiple queries and the first query has no conditions.

 The second query will return you 1 row - if you explicitly used joins
 or used one of the behaviors I mentioned that means you get what you
 asked for.

 If you're still in doubt - try it.

 hth,

 AD

 $this-







  On May 3, 3:55 pm, AD7six andydawso...@gmail.com wrote:

   On May 2, 1:45 pm, Jon Bennett jmbenn...@gmail.com wrote:

 i need to use Merchant model to do a find of all 4 related data.
 notice that Domain is the only one NOT directly related to Merchant.

 i tried this in a method inside Merchant model:

 $this-Behaviors-attach('Containable');
 $this-User-Behaviors-attach('Containable');
 $this-Shop-Behaviors-attach('Containable');
 $this-Shop-Domain-Behaviors-attach('Containable');

 $this-recursive = -1;
 $this-User-recursive = -1;
 $this-Shop-recursive = -1;
 $this-Shop-Domain-recursive = -1;

 return $this-find('first',
                array(
                  'contain'=array(
                                         'User',
                                         'Shop' = array('Domain' ),

                                        ),
                'conditions' = $conditions
        ));

http://book.cakephp.org/view/1323/Containablehaserrorsinterms of
 telling you where to place the conditions. my way is correct as of 1.3
 Cakephp

return $this-find('first', array(
        // conditions for the main model
        'conditions'=array(),
        // contain
        'contain'=array(
                'User'=array(
                        // conditions for the user model
                        'conditions'=array('User.status'=1),
                        'Other', 'Models', 'From', 'User'
                ),
                'Shop'=array('Domain'),
        )
));

   Using conditions like that is the equivalent of a right join - you're
   still going to get every single main model row - and just get an
   empty array for any row which links to a user with a status that isn't
   1.

   hth,

   AD

   Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpothers 
   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 
   athttp://groups.google.com/group/cake-php?hl=en

  Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others 
  with their CakePHP related questions.

  You received this message because you are subscribed to the Google

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Kei Simone
Hi Andrei,

my first kneejerk feeling is that you are not paying attention to my
previous reply with the schema attached.

but i am going to ignore that feeling and assume that probably it was
my communication that was bad.

1) let me rephrase the schema again.

User
  -id
  -email
  -password
  -name

Merchant
  -id
  -user_id
  -shop_id
  -owner

Shop
  -id
  -name
  -description

Domain
  -id
  -domain
  -primary

Once again, the associations are that:
  User hasOne Merchant
  Shop hasMany Merchant
  Shop hasMany Domain

I am looking to grab data from Merchant model.

The conditions are

Domain.primary =1
User.email = a...@a.com
Merchant.owner = 1

I want to grab the FIRST data row that matches the conditions.

the datarow must have data from all 4 models.

2)

No i have not tried the find all with recursive 2

there are 3 reasons:

1) my joins is already working. my purpose in starting this thread is
to see if

a) i can do it in containable because i am forseeing a lot of similar
(complex find) situations cropping up down the line and if Containable
behavior is core then there must be a good reason to use it over
joins.

b) i REALLY REALLY want to get better at cakephp hence understanding
and studying Containable a core behavior is essential

since my joins is already working i have less inclination to try out
the find all with recursive 2.

2) my merchants and shops and users model have 4 to 6 Other models
tied to them EACH.

Recursive 2 would be mean retrieving a lot of data. I am assuming this
from the docs i read in book.cakephp.org esp the articles on
Containable. in fact this is the very reason why Containable was
promoted to solve this very same issue.

Unless of course i misinterpret your meaning. then i shall try it out.
but only if you give me exact details.

I am a 1 month old in terms of cake usage despite reading the docs
extensively i may still need quite a bit of hand holding.

3) i want to find the first datarow that matches the condition not
ALL. minor point of course i could easily change it to find first with
recursive 2 but then reason 2 would still stand.


I am truly sorry if what i said is rude or offends you. At work and at
home, i have been labelled as harsh and insensitive.

At times i wonder if i am autistic.

But this (obsessive) search to understand how the heck to get complex
search right and get a true understanding of cake is driving me to go
full out to seek answers so please forgive me should you be offended.

Thank you.

On May 4, 7:49 pm, Andrei Mita andrei.m...@gmail.com wrote:
 I'm having a hard time understanding your problem, probably it's just me,
 I'm not having a good time at work.

 So, if you have 4 tables all linked together (it doesn't matter if Shop
 links to User through Merchant), than my guess is that Containable would be
 the quickest way to get the data you want from all 4 tables.

 As I said in a previous e-mail. Do you know what you get if you do a
 find('all') with $recursive = 2? How much of that information you don't
 need.

 I can help you in two ways: either you give me the table structures and an
 example of what you want OR i can post a containable query from one of my
 projects that gets data from 4-5 different tables, as an example.





 On Tue, May 4, 2010 at 2:06 PM, Kei Simone kimc...@gmail.com wrote:
  i have the following for my cake 1.3:

  User hasOne Merchant (so Merchant belongsTo User)
  Shop hasMany Merchant (so Merchant belongsTo Shop as well.)
  Shop hasMany Domain (so Domain belongsTo Shop.)

  i need to use Merchant model to do a find of all 4 related data.

  i need to find the first datarow that matches conditions for Merchant,
  User and Domain.

  Merchant.owner = 1
  User.email = a...@a.com
  Domain.domain =http://abc.example.com
  Domain.primary = 1

  the datarow must contain data from all 4 models.

  the find must be done inside the Merchant model. as in $this-find...

  Love to hear more from you about Containable. Really interested to see
  how powerful Containable is.

 Check out the new CakePHP Questions sitehttp://cakeqs.organd 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 
 athttp://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: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Kei Simone
Hi Jeremy,

thank you for answering.

I agree with you that it would be silly of me to keep emphasizing to
do the find from merchant. i would readily accept a solution that does
it elegantly even if the find starts from another model.

For instance, i tried out Jon's example code and subsequently put up
the resultant sql query and results. you can see the ultra long post.

My gut feeling tells me that I do not see any significant difference
even if i start from User model.

But of course i would be more convinced if

a) you point out the exact reason why starting from User would prove
to be different this time.

OR

b) like jon, you put up some example code for me to try out.

at the very least my guess is that either Merchant or Shop would be
the best to start from since the associations look like this

User - Merchant - Shop - Domain

Thank you for taking time to answer though. I appreciate all input.


On May 4, 7:15 pm, Jeremy Burns jeremybu...@me.com wrote:
 The find does not have to be done from the Merchant model. If the models are 
 related if sometimes makes sense to hop across to another model to start the 
 find from there (I often do this). If it makes more sense to start it from, 
 say, the User model, then you can do $this-Merchant-User-find() and 
 contain the Merchant, Shop and Domain models.

 Jeremy Burns
 jeremybu...@me.com
 On 4 May 2010, at 12:06, Kei Simone wrote:



  i have the following for my cake 1.3:

  User hasOne Merchant (so Merchant belongsTo User)
  Shop hasMany Merchant (so Merchant belongsTo Shop as well.)
  Shop hasMany Domain (so Domain belongsTo Shop.)

  i need to use Merchant model to do a find of all 4 related data.

  i need to find the first datarow that matches conditions for Merchant,
  User and Domain.

  Merchant.owner = 1
  User.email = a...@a.com
  Domain.domain =http://abc.example.com
  Domain.primary = 1

  the datarow must contain data from all 4 models.

  the find must be done inside the Merchant model. as in $this-find...

  Love to hear more from you about Containable. Really interested to see
  how powerful Containable is.

  On May 3, 3:33 pm, Andrei Mita andrei.m...@gmail.com wrote:
  Simone,

  Containable is extremely powerful. I am just amazed how little time it 
  takes
  me to write complex queries.

  Give me the structure of the tables and an example of what do you want to
  retrieve from them and I might be able to help you around.

  On Mon, May 3, 2010 at 8:02 AM, Kei Simone kimc...@gmail.com wrote:
  Hi i did this

  $this-Behaviors-attach('Containable');
                 $this-User-Behaviors-attach('Containable');
                 $this-Shop-Behaviors-attach('Containable');
                 $this-Shop-Domain-Behaviors-attach('Containable');

                 $this-recursive = -1;
                 $this-User-recursive = -1;
                 $this-Shop-recursive = -1;
                 $this-Shop-Domain-recursive = -1;

                 return $this-find('first', array(
                          // conditions for the main model
                          'conditions'=array('Merchant.owner'=1),
                          // contain
                         'contain'=array(
                                 'User'=array(
                                         // conditions for the user model

   'conditions'=array('User.group_id'=MERCHANTS,
                                                             'User.email' =
  'a...@a.com',),

                                 ),
                                 'Shop'=array(

   'conditions'=array('Shop.web_address' = 'http://
  abc.myspree2shop.com',),
                                               'Domain'),
                         )
                 ));

  i got this in the sql query log

  SELECT `Merchant`.`id`, `Merchant`.`owner`, `Merchant`.`shop_id`,
  `Merchant`.`user_id`, `Shop`.`id`, `Shop`.`theme_id`, `Shop`.`name`,
  `Shop`.`web_address`, `Shop`.`created_on`, `Shop`.`modified_on`,
  `Shop`.`status`, `User`.`id`, `User`.`email`, `User`.`password`,
  `User`.`group_id`, `User`.`full_name`, `User`.`name_to_call`,
  `User`.`last_login_on`, `User`.`status`, `User`.`created_on`,
  `User`.`modified_on` FROM `merchants` AS `Merchant` LEFT JOIN `shops`
  AS `Shop` ON (`Merchant`.`shop_id` = `Shop`.`id` AND
  `Shop`.`web_address` = 'http://abc.myspree2shop.com') LEFT JOIN
  `users` AS `User` ON (`Merchant`.`user_id` = `User`.`id` AND
  `User`.`group_id` = 3 AND `User`.`email` = 'a...@a.com') WHERE
  `Merchant`.`owner` = 1 LIMIT 1

  SELECT `Shop`.`id`, `Shop`.`theme_id`, `Shop`.`name`,
  `Shop`.`web_address`, `Shop`.`created_on`, `Shop`.`modified_on`,
  `Shop`.`status` FROM `shops` AS `Shop` WHERE `Shop`.`id` = 1 AND
  `Shop`.`web_address` = 'http://abc.myspree2shop.com'

  SELECT `User`.`id`, `User`.`email`, `User`.`password`,
  `User`.`group_id`, `User`.`full_name`, `User`.`name_to_call`,
  `User`.`last_login_on`, `User`.`status`, `User`.`created_on`,
  `User`.`modified_on` FROM `users` AS `User

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Kei Simone
Hi Andrei,

thanks for your reply.

Here is my reply.

1) i agree with you when teaching or helping out you learn faster.
i have some personal experience of that myself. I am sure you mean no
malice and was also trying to be helpful.

2) unfortunately i think what you suggested was exactly what i tried
out ALREADY here. http://groups.google.com/group/cake-php/msg/fc2a2b9779c5b182

3) you must have wrote that message in a jiffy, because you have
ignored the fact that Domain is NOT directly connected to Merchant. i
am not going to paste the links. You can find all the schema i wrote
so far above.

4) I really appreciated your input, i think it is infinitely better
than having no one look at my problem at all.

5) Have a nice day.

On May 4, 9:16 pm, Andrei Mita andrei.m...@gmail.com wrote:
 Being a newbie to cakephp myself, I found out that by trying to help out
 other people I get to learn it better and faster. I did pay attention but,
 as I told you, I'm not having a good time right now and most probably that's
 why I didn't get you problem the first time.

 Feelings aside :), here is how I do things when it comes to complex-ish
 queries. First, I try the recursive = 2 and a debug  on the var to see
 exactly how much data I'm getting and how much do I need to take out. That's
 why I was bugging you with that. When you have the debugged array in from of
 you it's very easy to write the containable query.

 First, attach Containable on the fly in the view action:
 $this-Merchant-attach('Containable');

 Then the query:

 $merchant = $this-Merchant-find('first', array(
                                             'contain' = array(
                                                             'User' =
 array('conditions' = array('User.email' = $email)),
                                                             'Domain' =
 array('conditions' = array('Domain.primary' = $primary)),
                                                             'Shop'
                                                          ),
                                             'conditions' =
 array('Merchant.owner' = $owner)
                                            )
                                   );

 I've wrote this blindfolded and I have no idea if it will work, but i think
 it's a good start. I'll test case it myself if it's necessary.





 On Tue, May 4, 2010 at 3:48 PM, Kei Simone kimc...@gmail.com wrote:
  Hi Andrei,

  my first kneejerk feeling is that you are not paying attention to my
  previous reply with the schema attached.

  but i am going to ignore that feeling and assume that probably it was
  my communication that was bad.

  1) let me rephrase the schema again.

  User
   -id
   -email
   -password
   -name

  Merchant
   -id
   -user_id
   -shop_id
   -owner

  Shop
   -id
   -name
   -description

  Domain
   -id
   -domain
   -primary

  Once again, the associations are that:
   User hasOne Merchant
   Shop hasMany Merchant
   Shop hasMany Domain

  I am looking to grab data from Merchant model.

  The conditions are

  Domain.primary =1
  User.email = a...@a.com
  Merchant.owner = 1

  I want to grab the FIRST data row that matches the conditions.

  the datarow must have data from all 4 models.

  2)

  No i have not tried the find all with recursive 2

  there are 3 reasons:

  1) my joins is already working. my purpose in starting this thread is
  to see if

  a) i can do it in containable because i am forseeing a lot of similar
  (complex find) situations cropping up down the line and if Containable
  behavior is core then there must be a good reason to use it over
  joins.

  b) i REALLY REALLY want to get better at cakephp hence understanding
  and studying Containable a core behavior is essential

  since my joins is already working i have less inclination to try out
  the find all with recursive 2.

  2) my merchants and shops and users model have 4 to 6 Other models
  tied to them EACH.

  Recursive 2 would be mean retrieving a lot of data. I am assuming this
  from the docs i read in book.cakephp.org esp the articles on
  Containable. in fact this is the very reason why Containable was
  promoted to solve this very same issue.

  Unless of course i misinterpret your meaning. then i shall try it out.
  but only if you give me exact details.

  I am a 1 month old in terms of cake usage despite reading the docs
  extensively i may still need quite a bit of hand holding.

  3) i want to find the first datarow that matches the condition not
  ALL. minor point of course i could easily change it to find first with
  recursive 2 but then reason 2 would still stand.

  I am truly sorry if what i said is rude or offends you. At work and at
  home, i have been labelled as harsh and insensitive.

  At times i wonder if i am autistic.

  But this (obsessive) search to understand how the heck to get complex
  search right and get a true understanding of cake is driving me to go
  full out to seek answers so

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Kei Simone
Hi AD7six,

i apologise if i have asked a question that can be easily answered if
i looked a little more closely.

but i am having some problems.

Here it is:

i tried this

$this-Behaviors-attach('OneQuery');
$this-User-Behaviors-attach('OneQuery');
$this-Shop-Behaviors-attach('OneQuery');
$this-Shop-Domain-Behaviors-attach('OneQuery');

debug('test');
return $this-find('first', array(
// linkable behavior in OneQuery
'link'=array(
'User',
'Shop'='Domain',
),
// conditions for the main model

'conditions'=array('Merchant.owner'=1,
'User.group_id'=MERCHANTS,
'User.email' = 'a...@a.com',
'Shop.web_address' = 
'http://abc.myspree2shop.com',),

));

i got this in my query:

SELECT `Merchant`.`id`, `Merchant`.`owner`, `Merchant`.`shop_id`,
`Merchant`.`user_id` FROM `merchants` AS `Merchant` WHERE
`Merchant`.`owner` = 1 AND `User`.`group_id` = 3 AND `User`.`email` =
'a...@a.com' AND `Shop`.`web_address` = 'http://abc.myspree2shop.com'

And this error message
1054: Unknown column 'User.group_id' in 'where clause'

So i tried to change it to look like one of your examples in your
blogpost.

$this-Behaviors-attach('OneQuery');
$this-User-Behaviors-attach('OneQuery');
$this-Shop-Behaviors-attach('OneQuery');
$this-Shop-Domain-Behaviors-attach('OneQuery');

debug('test');
return $this-find('all', array(
// linkable behavior in OneQuery
'link'=array(
'User',
'Shop'='Domain',
),


));

i get this instead

SELECT `Merchant`.`id`, `Merchant`.`owner`, `Merchant`.`shop_id`,
`Merchant`.`user_id` FROM `merchants` AS `Merchant` WHERE 1 = 1

and the data set ONLY containing Merchant data

Array
(
[0] = Array
(
[Merchant] = Array
(
[id] = 1
[owner] = 1
[shop_id] = 1
[user_id] = 1
)

)

[1] = Array
(
[Merchant] = Array
(
[id] = 2
[owner] = 1
[shop_id] = 2
[user_id] = 2
)

)

)

 i suspect i must have done something wrong. Please advise.

 Appreciate it greatly.




On May 4, 8:44 pm, AD7six andydawso...@gmail.com wrote:
 On May 4, 2:13 pm, sphereweb ggr...@gmail.com wrote:

  I would like to see your example that gets the data from 4-5 tables :)

 There's only 1 test case in it but you can see usage 
 here:http://github.com/AD7six/mi/blob/master/tests/cases/behaviors/one_que...

 Although the single test case is calling oneQuery explicitly - you
 normally use the behavior in exactly the same as containable
 (including you can configure onequery to look for the param name
 contain) but the result is - one query.

 hth,

 AD

 Check out the new CakePHP Questions sitehttp://cakeqs.organd 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 
 athttp://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: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Kei Simone
Perhaps i made a mistake in trying out jon's query. it does NOT get me
what i want. not even close.

I tend to agree with AD7six that Containable is not suitable for my
situation.

Thank you though. :)

On May 4, 10:18 pm, Andrei Mita andrei.m...@gmail.com wrote:
 OK, something is really wrong here. In my e-mail account there are just a
 couple of emails whereas in the group there are dozens.

 That explains a lot.

 The second query, the one suggested by Jon, was very close to get you what
 you wanted.





 On Tue, May 4, 2010 at 4:35 PM, Kei Simone kimc...@gmail.com wrote:
  Hi Andrei,

  thanks for your reply.

  Here is my reply.

  1) i agree with you when teaching or helping out you learn faster.
  i have some personal experience of that myself. I am sure you mean no
  malice and was also trying to be helpful.

  2) unfortunately i think what you suggested was exactly what i tried
  out ALREADY here.
 http://groups.google.com/group/cake-php/msg/fc2a2b9779c5b182

  3) you must have wrote that message in a jiffy, because you have
  ignored the fact that Domain is NOT directly connected to Merchant. i
  am not going to paste the links. You can find all the schema i wrote
  so far above.

  4) I really appreciated your input, i think it is infinitely better
  than having no one look at my problem at all.

  5) Have a nice day.

  On May 4, 9:16 pm, Andrei Mita andrei.m...@gmail.com wrote:
   Being a newbie to cakephp myself, I found out that by trying to help out
   other people I get to learn it better and faster. I did pay attention
  but,
   as I told you, I'm not having a good time right now and most probably
  that's
   why I didn't get you problem the first time.

   Feelings aside :), here is how I do things when it comes to complex-ish
   queries. First, I try the recursive = 2 and a debug  on the var to see
   exactly how much data I'm getting and how much do I need to take out.
  That's
   why I was bugging you with that. When you have the debugged array in from
  of
   you it's very easy to write the containable query.

   First, attach Containable on the fly in the view action:
   $this-Merchant-attach('Containable');

   Then the query:

   $merchant = $this-Merchant-find('first', array(
                                               'contain' = array(
                                                               'User' =
   array('conditions' = array('User.email' = $email)),
                                                               'Domain' =
   array('conditions' = array('Domain.primary' = $primary)),
                                                               'Shop'
                                                            ),
                                               'conditions' =
   array('Merchant.owner' = $owner)
                                              )
                                     );

   I've wrote this blindfolded and I have no idea if it will work, but i
  think
   it's a good start. I'll test case it myself if it's necessary.

   On Tue, May 4, 2010 at 3:48 PM, Kei Simone kimc...@gmail.com wrote:
Hi Andrei,

my first kneejerk feeling is that you are not paying attention to my
previous reply with the schema attached.

but i am going to ignore that feeling and assume that probably it was
my communication that was bad.

1) let me rephrase the schema again.

User
 -id
 -email
 -password
 -name

Merchant
 -id
 -user_id
 -shop_id
 -owner

Shop
 -id
 -name
 -description

Domain
 -id
 -domain
 -primary

Once again, the associations are that:
 User hasOne Merchant
 Shop hasMany Merchant
 Shop hasMany Domain

I am looking to grab data from Merchant model.

The conditions are

Domain.primary =1
User.email = a...@a.com
Merchant.owner = 1

I want to grab the FIRST data row that matches the conditions.

the datarow must have data from all 4 models.

2)

No i have not tried the find all with recursive 2

there are 3 reasons:

1) my joins is already working. my purpose in starting this thread is
to see if

a) i can do it in containable because i am forseeing a lot of similar
(complex find) situations cropping up down the line and if Containable
behavior is core then there must be a good reason to use it over
joins.

b) i REALLY REALLY want to get better at cakephp hence understanding
and studying Containable a core behavior is essential

since my joins is already working i have less inclination to try out
the find all with recursive 2.

2) my merchants and shops and users model have 4 to 6 Other models
tied to them EACH.

Recursive 2 would be mean retrieving a lot of data. I am assuming this
from the docs i read in book.cakephp.org esp the articles on
Containable. in fact this is the very reason why Containable was
promoted to solve this very same

Re: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Kei Simone
Hi Andy,

i got it to work using Linkable. as well as you suggested by using
bindModel which is slightly more readble than joins.

though i think linkable is really darn short and it looks good.

I am sorry, i apologise that i misunderstood.

I thought both the linkable and the onequery are the same. and i
thought you wrote both linkable and onequery.

i got a few questions for clarification purposes. please help to
clarify.

1) i initially placed the linkable directly in app/models/behaviors/
linkable.php

having recalled my meio_upload, i realised that the behavior file was
actually stored at plugins/meio_upload/models/behaviors/
meio_upload.php.

so i did the same for linkable and called the file using $this-
Behaviors-attach(Linkable.Linkable);

so i should place such code in plugins ALWAYS?

2) your onequery is doing the same thing as Linkable yes? as in
optimizing the query. so to use it i need only placed it in plugins/mi/
models/behaviors/one_query.php

do i need the other mi files?

3) i am preparing a simple notes on the differences of using Linkable,
Containable and the standard recursive-find. hopefully by then i can
ask you to fill in the gaps in my knowledge.

Thank you.

On May 4, 11:12 pm, AD7six andydawso...@gmail.com wrote:
 On May 4, 4:24 pm, Kei Simone kimc...@gmail.com wrote:

  Hi AD7six,

  i apologise if i have asked a question that can be easily answered if
  i looked a little more closely.

 I think you have a misunderstanding of what a plugin  is (see the
 book) and are mixing the usage of two different behaviors together -
 see the test case OR just use linkable and follow the docs /for that/.

 http://bin.cakephp.org/view/19424286(I haven't changed your incorrect
 code because there's an error on every line)

 AD

 Check out the new CakePHP Questions sitehttp://cakeqs.organd 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 
 athttp://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: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-04 Thread Kei Simone
Hi Andy,

so in conclusion, i should get into the habit of installing these cake
files as plugins.

Thank you.

I didn't try your one_query cause i tried reading it but i dont quite
understand how to use it.

Hope you dont mind.

however, you have been the most helpful to me so far in pointing me
the way.

Thank you.



On May 5, 3:58 am, AD7six andydawso...@gmail.com wrote:
 On May 4, 7:19 pm, Kei Simone kimc...@gmail.com wrote:





  Hi Andy,

  i got it to work using Linkable. as well as you suggested by using
  bindModel which is slightly more readble than joins.

  though i think linkable is really darn short and it looks good.

  I am sorry, i apologise that i misunderstood.

  I thought both the linkable and the onequery are the same. and i
  thought you wrote both linkable and onequery.

  i got a few questions for clarification purposes. please help to
  clarify.

  1) i initially placed the linkable directly in app/models/behaviors/
  linkable.php

  having recalled my meio_upload, i realised that the behavior file was
  actually stored at plugins/meio_upload/models/behaviors/
  meio_upload.php.

  so i did the same for linkable and called the file using $this-

  Behaviors-attach(Linkable.Linkable);

  so i should place such code in plugins ALWAYS?

 I'd suggest: If it's distributed as a plugin yes otherwise: no. Plugin
 models and controllers extend a different class (PluginApp(Controller|
 Model)) which might mean if you follow your rule you come unstuck at
 some point although a behavior doesn't know if it's in a plugin or not
 so in this instance you can choose.



  2) your onequery is doing the same thing as Linkable yes?

 Yes - more or less. I didn't know of linkable when I wrote it.

 as in

  optimizing the query. so to use it i need only placed it in plugins/mi/
  models/behaviors/one_query.php

 kind of



  do i need the other mi files?

 I don't think so but mi is a plugin - I'd suggest getting into the
 habit of installing plugins (cd plugins  git clone git://.) -
 not individual files.

 If you choose to use it (attach it and just replace contain in your
 find call with oneQuery, OR attach it and tell the behavior to look
 for the param contain) and it complains, then it does ;)
 hth,

 AD

 Check out the new CakePHP Questions sitehttp://cakeqs.organd 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 
 athttp://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


The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-02 Thread Kei Simone
Hi,

i have the following for my cake 1.3:

User hasOne Merchant (so Merchant belongsTo User)
Shop hasMany Merchant (so Merchant belongsTo Shop as well.)
Shop hasMany Domain (so Domain belongsTo Shop.)

i need to use Merchant model to do a find of all 4 related data.
notice that Domain is the only one NOT directly related to Merchant.

i tried this in a method inside Merchant model:

$this-Behaviors-attach('Containable');
$this-User-Behaviors-attach('Containable');
$this-Shop-Behaviors-attach('Containable');
$this-Shop-Domain-Behaviors-attach('Containable');

$this-recursive = -1;
$this-User-recursive = -1;
$this-Shop-recursive = -1;
$this-Shop-Domain-recursive = -1;

return $this-find('first',
array(
  'contain'=array(
 'User',
 'Shop' = array('Domain' ),

),
'conditions' = $conditions
));

http://book.cakephp.org/view/1323/Containable has errors in terms of
telling you where to place the conditions. my way is correct as of 1.3
Cakephp

but there is no way to get the Domain.

I also noticed that the doc told us about using fields.

it is so vague i am not even sure what fields to put inside. they
mentioned that foreign keys but do the example like id, name, note
look like foreign key? they look like primary key and field .

another thing is it is not consistent. look at AccountSummary and
compare it with PostAttachment.

both are 2 models away from main model but AccountSummary does not
need to use fields, i wonder why PostAttachment needs it?

anyway if you have problems with complicated search, like mine, use
joins. more reliable than Containable  see 
http://book.cakephp.org/view/1047/Joining-tables

please advise me on how to use Containable so i can use it instead of
custom queries.

Thank you

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: The docs for Containable does not work for complex search. Complex search is 2 models away. For cake 1.3

2010-05-02 Thread Kei Simone
Hi i did this

$this-Behaviors-attach('Containable');
$this-User-Behaviors-attach('Containable');
$this-Shop-Behaviors-attach('Containable');
$this-Shop-Domain-Behaviors-attach('Containable');

$this-recursive = -1;
$this-User-recursive = -1;
$this-Shop-recursive = -1;
$this-Shop-Domain-recursive = -1;


return $this-find('first', array(
// conditions for the main model
'conditions'=array('Merchant.owner'=1),
// contain
'contain'=array(
'User'=array(
// conditions for the user model

'conditions'=array('User.group_id'=MERCHANTS,
'User.email' = 
'a...@a.com',),

),
'Shop'=array(
'conditions'=array('Shop.web_address' 
= 'http://
abc.myspree2shop.com',),
  'Domain'),
)
));


i got this in the sql query log

SELECT `Merchant`.`id`, `Merchant`.`owner`, `Merchant`.`shop_id`,
`Merchant`.`user_id`, `Shop`.`id`, `Shop`.`theme_id`, `Shop`.`name`,
`Shop`.`web_address`, `Shop`.`created_on`, `Shop`.`modified_on`,
`Shop`.`status`, `User`.`id`, `User`.`email`, `User`.`password`,
`User`.`group_id`, `User`.`full_name`, `User`.`name_to_call`,
`User`.`last_login_on`, `User`.`status`, `User`.`created_on`,
`User`.`modified_on` FROM `merchants` AS `Merchant` LEFT JOIN `shops`
AS `Shop` ON (`Merchant`.`shop_id` = `Shop`.`id` AND
`Shop`.`web_address` = 'http://abc.myspree2shop.com') LEFT JOIN
`users` AS `User` ON (`Merchant`.`user_id` = `User`.`id` AND
`User`.`group_id` = 3 AND `User`.`email` = 'a...@a.com') WHERE
`Merchant`.`owner` = 1 LIMIT 1


SELECT `Shop`.`id`, `Shop`.`theme_id`, `Shop`.`name`,
`Shop`.`web_address`, `Shop`.`created_on`, `Shop`.`modified_on`,
`Shop`.`status` FROM `shops` AS `Shop` WHERE `Shop`.`id` = 1 AND
`Shop`.`web_address` = 'http://abc.myspree2shop.com'

SELECT `User`.`id`, `User`.`email`, `User`.`password`,
`User`.`group_id`, `User`.`full_name`, `User`.`name_to_call`,
`User`.`last_login_on`, `User`.`status`, `User`.`created_on`,
`User`.`modified_on` FROM `users` AS `User` WHERE `User`.`id` = 1 AND
`User`.`group_id` = 3 AND `User`.`email` = 'a...@a.com'



i got this result

Array
(
[Merchant] = Array
(
[id] = 1
[owner] = 1
[shop_id] = 1
[user_id] = 1
)

[Shop] = Array
(
[id] =
[theme_id] =
[name] =
[web_address] =
[created_on] =
[modified_on] =
[status] =
)

[User] = Array
(
[id] =
[email] =
[password] =
[group_id] =
[full_name] =
[name_to_call] =
[last_login_on] =
[status] =
[created_on] =
[modified_on] =
)

)




When i changed your recommendation to

return $this-find('first',
array(
  'contain'=array(
   'User',
   'Shop' = 
array('Domain'
),


   ),
  'conditions' = 
array('User.group_id'=MERCHANTS,
'User.email' = 
'a...@a.com',
 
'Shop.web_address' = 'http://abc.myspree2shop.com',
   )
  )
);


all i did was to move all the conditions to the main model.

i got this in my sql query log:
SELECT `Merchant`.`id`, `Merchant`.`owner`, `Merchant`.`shop_id`,
`Merchant`.`user_id`, `Shop`.`id`, `Shop`.`theme_id`, `Shop`.`name`,
`Shop`.`web_address`, `Shop`.`created_on`, `Shop`.`modified_on`,
`Shop`.`status`, `User`.`id`, `User`.`email`, `User`.`password`,
`User`.`group_id`, `User`.`full_name`, `User`.`name_to_call`,
`User`.`last_login_on`, `User`.`status`, `User`.`created_on`,
`User`.`modified_on` FROM `merchants` AS `Merchant` LEFT JOIN `shops`
AS `Shop` ON (`Merchant`.`shop_id` = `Shop`.`id`) LEFT JOIN `users` AS
`User` ON (`Merchant`.`user_id` = `User`.`id`) WHERE `User`.`group_id`
= 3 AND `User`.`email` = 'a...@a.com' AND `Shop`.`web_address` =
'http://abc.myspree2shop.com' LIMIT 1

SELECT `Shop`.`id`, `Shop`.`theme_id`, `Shop`.`name`,
`Shop`.`web_address`,