help me to join the table with associative table using hasAndBelongsToMany

2014-03-20 Thread REnu Varghese



i have 4 tables with following data

+ businesses(table 1) its fields are : id, business_name, brand_id

+ categories(table 2) its fields are : id, category_name

+ business_categories(table 3) its fields are : id, business_id , 
category_id

+ brands(table 4) its fields are id, brand_name

> Business and Category tables are related with business_categories table

I got the correct result of all Business based on Category 

my model page Category.php is here pasting

$this->bindModel(
array(
'hasAndBelongsToMany' => array(
'Business' => array(
'className' => 'Business', 
'joinTable' => 'business_categories', 
'foreignKey' => 'category_id',
'associationForeignKey' => 'business_id', 
'with' => 'BusinessCategory'
;
$category = $this->find('all');

My question is how i can join the Brand(table 4) with Business in this code.

Brand table is related with each Business table brand_id is the primary 
key(id) of Brand table

Help me please, Thanks in advance.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


join tables with associated table using hasAndBelongsToMany

2014-03-20 Thread REnu Varghese


i have 4 tables with following data

+ businesses(table 1) its fields are : id, business_name, brand_id

+ categories(table 2) its fields are : id, category_name

+ business_categories(table 3) its fields are : id, business_id , 
category_id

+ brands(table 4) its fields are id, brand_name

> Business and Category tables are related with business_categories table

I got the correct result of all Business based on Category 

my model page Category.php is here pasting

$this->bindModel(
array(
'hasAndBelongsToMany' => array(
'Business' => array(
'className' => 'Business', 
'joinTable' => 'business_categories', 
'foreignKey' => 'category_id',
'associationForeignKey' => 'business_id', 
'with' => 'BusinessCategory'
;
$category = $this->find('all');

My question is how i can join the Brand(table 4) with Business in this code.

Brand table is related with each Business table 
‪#‎brand_id‬is the 
primary key(id) of Brand table

Help me please, Thanks in advance.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: is this a threadsafe code?

2014-03-20 Thread Борислав Събев Borislav Sabev
Well in a sense it is "thread safe" since the executed php code will NOT 
actually thread itself.

@Gary Kremmer seems to be confusing terms.
Gary, there is no problem here since each and every user will get his own 
execution scope and instance of the code.

The fact that nginx forks itself for each request does not provide 
threading for the PHP script running on the server.

Borislav.

On Thursday, 20 March 2014 11:56:03 UTC+2, nicky wrote:
>
> I think this is nothing to do with thread safe , dont u think so ?
>
>
> On Wed, Mar 19, 2014 at 9:44 PM, Eugenio 
> > wrote:
>
>> Why not;
>> $myBoolean=(boolean) something;
>>
>>
>> 2014-03-18 9:29 GMT-03:00 Kamal Deol >:
>>
>> YES It is Thread Safe : 100% Sure
>>>
>>>
>>> On Tue, Mar 18, 2014 at 6:33 AM, Gary Kremmer 
>>> 
>>> > wrote:
>>>
 class SomeController extends AppController { 

 public function index() {
  if(something) {
$myBoolean=true;
   } else {
 $myBoolean=false;
 } //end of if 
  } //end of method
 } //end of class


 I am using nginx+php FPM. 

 My question is if there are multiple users hitting 
 the SomeController at the same time, is myBoolean threadsafe? 

 Thanks,
 Gary.

 -- 
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 --- 
 You received this message because you are subscribed to the Google 
 Groups "CakePHP" group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to cake-php+u...@googlegroups.com .
 To post to this group, send email to cake...@googlegroups.com
 .
 Visit this group at http://groups.google.com/group/cake-php.
 For more options, visit https://groups.google.com/d/optout.

>>>
>>>  -- 
>>> Like Us on FaceBook https://www.facebook.com/CakePHP
>>> Find us on Twitter http://twitter.com/CakePHP
>>>
>>> --- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "CakePHP" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to cake-php+u...@googlegroups.com .
>>> To post to this group, send email to cake...@googlegroups.com
>>> .
>>> Visit this group at http://groups.google.com/group/cake-php.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> -- 
>> *May the source be with you.*
>>  
>> -- 
>> Like Us on FaceBook https://www.facebook.com/CakePHP
>> Find us on Twitter http://twitter.com/CakePHP
>>
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "CakePHP" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to cake-php+u...@googlegroups.com .
>> To post to this group, send email to cake...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/cake-php.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: is this a threadsafe code?

2014-03-20 Thread Kamal Deol
I think this is nothing to do with thread safe , dont u think so ?


On Wed, Mar 19, 2014 at 9:44 PM, Eugenio  wrote:

> Why not;
> $myBoolean=(boolean) something;
>
>
> 2014-03-18 9:29 GMT-03:00 Kamal Deol :
>
> YES It is Thread Safe : 100% Sure
>>
>>
>> On Tue, Mar 18, 2014 at 6:33 AM, Gary Kremmer wrote:
>>
>>> class SomeController extends AppController {
>>>
>>> public function index() {
>>>  if(something) {
>>>$myBoolean=true;
>>>   } else {
>>> $myBoolean=false;
>>> } //end of if
>>>  } //end of method
>>> } //end of class
>>>
>>>
>>> I am using nginx+php FPM.
>>>
>>> My question is if there are multiple users hitting the SomeController at
>>> the same time, is myBoolean threadsafe?
>>>
>>> Thanks,
>>> Gary.
>>>
>>> --
>>> Like Us on FaceBook https://www.facebook.com/CakePHP
>>> Find us on Twitter http://twitter.com/CakePHP
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "CakePHP" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to cake-php+unsubscr...@googlegroups.com.
>>> To post to this group, send email to cake-php@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/cake-php.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
>> Like Us on FaceBook https://www.facebook.com/CakePHP
>> Find us on Twitter http://twitter.com/CakePHP
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "CakePHP" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to cake-php+unsubscr...@googlegroups.com.
>> To post to this group, send email to cake-php@googlegroups.com.
>> Visit this group at http://groups.google.com/group/cake-php.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> *May the source be with you.*
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cake-php+unsubscr...@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Load balance CakePHP between 2 EC2 instances

2014-03-20 Thread Anthony Baron
Hi John,

I'm reaching out to you because we have a cakephp site with daily page 
views in the 30-50k region. We have a number of issues with the site 
relating to database sessions, configuring our load balancer, setting up 
additional nodes, persistent session issues, and so on.

I would like to find out if you are interested in helping out with this 
site and I would be very happy to pay you for your services.

Is this something you'd be interested in?

Anthony


On Thursday, February 16, 2012 6:31:13 AM UTC+11, ibejohn818 wrote:
>
> No sticky sessions, through my experience with load balancing my 
> particular cakePHP application ( and various others ) I've found that 
> sticky sessions does not evenly balance the load across machines, 
> particularly if they are all serving site assets IE: images, style sheets, 
> javascripts
>
> However, the application that I run serves over 1 million pages a day and 
> 300k in unique users. 
>
> The biggest performance gain I've seen was when I moved caching ( 
> Including schema caching ) over to a dedicated "memcached" server.
>
> I've also moved over my PHP session to memcache VS database sessions and 
> seen a significant performance gain.
>
> If you have any other questions feel free to ask and I'll try and advise 
> where I can.
>
> On Feb 15, 2012, at 8:28 AM, Andres Montiel, CUA wrote:
>
> Thanks John. I also see that you're using HAProxy for the cluster. Sticky 
> sessions for CakePHP?
>
> On Thu, Feb 16, 2012 at 12:08 AM, John Hardy 
> > wrote:
>
>> Yes.
>>
>> I have a cluster of 6 nodes serving my site. 
>>
>> 
>>
>> On Feb 14, 2012, at 5:19 PM, kyutums wrote:
>>
>> We are currently using CodeIgniter in another project. To handle large
>> traffic (we get around 60k pageviews per day), we load balance between
>> 2 EC2 instances.
>>
>> Is it possible to load balance using CakePHP as well? Also, would it
>> be easy to add another server in the cluster using CakePHP?
>>
>> -- 
>> Our newest site for the community: CakePHP Video Tutorials 
>> http://tv.cakephp.org 
>> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
>> others with their CakePHP related questions.
>>
>>
>> To unsubscribe from this group, send email to
>> cake-php+u...@googlegroups.com  For more options, visit 
>> this group at http://groups.google.com/group/cake-php
>>
>>
>>
>> -- 
>> Our newest site for the community: CakePHP Video Tutorials 
>> http://tv.cakephp.org 
>> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
>> others with their CakePHP related questions.
>>  
>>  
>> To unsubscribe from this group, send email to
>> cake-php+u...@googlegroups.com  For more options, visit 
>> this group at http://groups.google.com/group/cake-php
>>
>
>
> -- 
> Our newest site for the community: CakePHP Video Tutorials 
> http://tv.cakephp.org 
> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
> others with their CakePHP related questions.
>  
>  
> To unsubscribe from this group, send email to
> cake-php+u...@googlegroups.com  For more options, visit this 
> group at http://groups.google.com/group/cake-php
>
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


using ->query to update

2014-03-20 Thread AugustoA
Hi guys,
I`m trying to do a update using a SQL query directly.
I`m having a strange behavior here, I use a similar query in another part 
of the code and it is updating normally.
When I use in the second part the update is updating the value as null.
I log the generated query and execute it directly into the DB and it works 
perfectly.
The query is
* $query = $this->query("update stocks, (select  supply_id, action_id, qtd, 
qtd_total from actions_supplies where action_id= '".$id."') act_sup set 
stocks.qtd = (stocks.qtd + act_sup.qtd_total) where stocks.supply_id = 
act_sup.supply_id and flag_waiting = 'Y' and flag_original = 'N' and 
area_id = (select area_id from glebes where id = '".$glebe_id."')");*
Does anyone had a similar behavior?
Any clues on how to fix this?
Thanks!
Augusto

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.