Re: Basic data fetching

2014-08-28 Thread Stephen S
I would recommend changing recursive to -1 in the AppModel and using
Containable, this way the only data you receive is the data you actually
request and could possibly help your application in terms of speed by
switching this off.
http://book.cakephp.org/2.0/en/core-libraries/behaviors/containable.html

To populate a select box you can just do something like the following in
your controller:
$this-set('devices', $this-Customer-Device-find('list')); If you name
devices appropriately it will automatically populate the select box,
otherwise you must specify like such:

echo $this-Form-input('device_id', array('options' = 'devices', 'empty'
= '-'));

Using device_id in the input and devices as the variable name should auto
populate the input field, you can also pass empty to create a blank option
first, and also you don't normally need to specify the input as select.


On 27 August 2014 21:47, Andras Kende and...@gmail.com wrote:

 Try something like

 $this-set('customer info',$this-Customer-find('first',array('recursive'
 = -1, 'conditions' = array('id'=$customerId;
 adding 'recursive' = -1 will only get the customer data..

 to get e select list for a customer devices
 $this-set('customer
 info',$this-Customer-Device-find('list',array('conditions' =
 array('customer_id'=$customerId;

 http://book.cakephp.org/2.0/en/models/retrieving-your-data.html

 Andras Kende


 On Aug 27, 2014, at 12:25 PM, Tristan Plumley plumleytris...@gmail.com
 wrote:

  Hello, I'm fairly new to cakephp and have a few pretty basic questions
 about fetching data from arrays:
 
  here is what i have set up
 
  Models:
 
  class Customer extends AppModel {
 
 
   public $hasMany = array('Device','Change');
 
  }
 
  class Device extends AppModel {
 
 
   public $belongsTo = 'Customer';
  }
 
 
  class Change extends AppModel {
 
 
   public $belongsTo = 'Customer';
  }
 
 
  now anytime I
 
 $this-set('customerinfo',$this-Customer-find('first',array('conditions'
 = array('id'=$customerId;
 
  or find('all'), i get everything on that customer, including all devices
 and all thousands of changes.
 
  One of my questions is how should i manage that relationship since i
 dont want to pull that much change data just to get a customer ID, name and
 address?
 
  Have I built my model relationships too simple to allow for me for
 limiting what is being sent?
 
 
  question #2
 
  doing the above statement, i get the following returned:
 
 
  array(
'Customer' = array(
'id' = '33',
'name' = 'customer#33',
'totchngavail' = '5',
'totalchanges' = '0'
),
'Device' = array(
(int) 0 = array(
'id' = '6',
'customer_id' = '33',
'name' = 'device4',
'type' = 'server',
'os' = 'aix',
'ip' = '123.123.123.123'
),
(int) 1 = array(
'id' = '31',
'customer_id' = '33',
'name' = 'dev2',
'type' = 'server',
'os' = 'linux',
'ip' = '123.123.123.123'
)
),
'Change' = array(
(int) 0 = array(
'id' = '2',
'customer_id' = '33',
'name' = 'change12',
'number' = '1234567890'
),
(int) 1 = array(
'id' = '4',
'customer_id' = '33',
'name' = 'change14',
'number' = '1234567890'
)
 
   ///many many more changes
)
  )
 
 
 
  When i try and retrieve all the devices for that customer in a select
 box for example i try with:
 
  echo $this-Form-input('device_id',array('label'= 'Device
 Name','style' = 'width: 150px;','type' = 'select',
  'options' = displayDevices($customerinfo)));
 
  and here is the displayDevices function:
 
  function displayDevices($customerinfo){
  //a list 'header' so no device is selected by default
   $var =array(NULL='---');
   foreach($customerinfo['Device'] as $device)
   {
   $var+=array($device['id']=$device['name']);
   }
   return $var;
  };
 
 
  So my question is: shouldnt there be a better way of displaying that
 select list? maybe by some form of $customerinfo['Device']['name'] right
 into the form input? When i do this i get an index error. I dont see how i
 should have to manually build an array to populate the select list when the
 complete customer array with devices comes in from the controller.
 
 
  thanks in advance for your advice.
 
 
  --
  Like Us on FaceBook https://www.facebook.com/CakePHP
  Find us on Twitter http://twitter.com/CakePHP
 
  ---
  You received this message because you are 

Re: Basic data fetching

2014-08-28 Thread Stephen S
'options' = $devices, sorry.


On 28 August 2014 07:07, Stephen S hellospeak...@gmail.com wrote:

 I would recommend changing recursive to -1 in the AppModel and using
 Containable, this way the only data you receive is the data you actually
 request and could possibly help your application in terms of speed by
 switching this off.
 http://book.cakephp.org/2.0/en/core-libraries/behaviors/containable.html

 To populate a select box you can just do something like the following in
 your controller:
 $this-set('devices', $this-Customer-Device-find('list')); If you name
 devices appropriately it will automatically populate the select box,
 otherwise you must specify like such:

 echo $this-Form-input('device_id', array('options' = 'devices', 'empty'
 = '-'));

 Using device_id in the input and devices as the variable name should auto
 populate the input field, you can also pass empty to create a blank option
 first, and also you don't normally need to specify the input as select.


 On 27 August 2014 21:47, Andras Kende and...@gmail.com wrote:

 Try something like

 $this-set('customer
 info',$this-Customer-find('first',array('recursive' = -1, 'conditions'
 = array('id'=$customerId;
 adding 'recursive' = -1 will only get the customer data..

 to get e select list for a customer devices
 $this-set('customer
 info',$this-Customer-Device-find('list',array('conditions' =
 array('customer_id'=$customerId;

 http://book.cakephp.org/2.0/en/models/retrieving-your-data.html

 Andras Kende


 On Aug 27, 2014, at 12:25 PM, Tristan Plumley plumleytris...@gmail.com
 wrote:

  Hello, I'm fairly new to cakephp and have a few pretty basic questions
 about fetching data from arrays:
 
  here is what i have set up
 
  Models:
 
  class Customer extends AppModel {
 
 
   public $hasMany = array('Device','Change');
 
  }
 
  class Device extends AppModel {
 
 
   public $belongsTo = 'Customer';
  }
 
 
  class Change extends AppModel {
 
 
   public $belongsTo = 'Customer';
  }
 
 
  now anytime I
 
 $this-set('customerinfo',$this-Customer-find('first',array('conditions'
 = array('id'=$customerId;
 
  or find('all'), i get everything on that customer, including all
 devices and all thousands of changes.
 
  One of my questions is how should i manage that relationship since i
 dont want to pull that much change data just to get a customer ID, name and
 address?
 
  Have I built my model relationships too simple to allow for me for
 limiting what is being sent?
 
 
  question #2
 
  doing the above statement, i get the following returned:
 
 
  array(
'Customer' = array(
'id' = '33',
'name' = 'customer#33',
'totchngavail' = '5',
'totalchanges' = '0'
),
'Device' = array(
(int) 0 = array(
'id' = '6',
'customer_id' = '33',
'name' = 'device4',
'type' = 'server',
'os' = 'aix',
'ip' = '123.123.123.123'
),
(int) 1 = array(
'id' = '31',
'customer_id' = '33',
'name' = 'dev2',
'type' = 'server',
'os' = 'linux',
'ip' = '123.123.123.123'
)
),
'Change' = array(
(int) 0 = array(
'id' = '2',
'customer_id' = '33',
'name' = 'change12',
'number' = '1234567890'
),
(int) 1 = array(
'id' = '4',
'customer_id' = '33',
'name' = 'change14',
'number' = '1234567890'
)
 
   ///many many more changes
)
  )
 
 
 
  When i try and retrieve all the devices for that customer in a select
 box for example i try with:
 
  echo $this-Form-input('device_id',array('label'= 'Device
 Name','style' = 'width: 150px;','type' = 'select',
  'options' = displayDevices($customerinfo)));
 
  and here is the displayDevices function:
 
  function displayDevices($customerinfo){
  //a list 'header' so no device is selected by default
   $var =array(NULL='---');
   foreach($customerinfo['Device'] as $device)
   {
   $var+=array($device['id']=$device['name']);
   }
   return $var;
  };
 
 
  So my question is: shouldnt there be a better way of displaying that
 select list? maybe by some form of $customerinfo['Device']['name'] right
 into the form input? When i do this i get an index error. I dont see how i
 should have to manually build an array to populate the select list when the
 complete customer array with devices comes in from the controller.
 
 
  thanks in advance for your advice.
 
 
  --
  Like Us on FaceBook 

Re: Smarty with Cakephp 2.XX .

2014-08-28 Thread Dakota
PHP is a template engine, and CakePHP leverages it as such. Any particular 
reason why you want to run something else on top of PHP?

On Wednesday, 27 August 2014 12:48:14 UTC+2, sandee...@gmail.com wrote:

 Can anybody tell how to use Smarty with Cakephp 2.XX .
 Is good?
 Any other good template engine?


-- 
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: migration issue

2014-08-28 Thread Dakota
Hi Dallas,

Have you tried running the CakePHP 2 upgrade shell?

http://book.cakephp.org/2.0/en/console-and-shells/upgrade-shell.html#upgrade-shell

It does about 90% of the grunt work for you, renames directories, moves 
files, search and replace things like $html to $this-Html, etc.

On Thursday, 28 August 2014 02:25:13 UTC+2, Dallas wrote:

 one other thing Stephan, following a migration tutorial I didn't transfer 
 the old index.php from app/webroot/index.php - i kept the 2.5.3 clean 
 version.  Should I be bringing over code from the earlier version and addi 
 to 2.5.3 cake or just use the old version.  I am getting another error 
 regarding the dispatcher request response on that file?  Thank you for all 
 of your help. I am determined to get this back up.
 D

 On Tuesday, August 26, 2014 2:50:44 PM UTC-4, Stephen S wrote:

 Also your index method is outside of your class, is this deliberate? 


 On 26 August 2014 19:48, Stephen S hellos...@gmail.com wrote:

 It doesn't look like you're using the request handler in this controller 
 or the construct method, why not remove both? CakePHP 2.x controllers don't 
 really need to use construct, beforeFilter is usually more than sufficient.

 Hope this helps


 On 26 August 2014 17:31, 'Dallas' via CakePHP cake...@googlegroups.com 
 wrote:

 Andras,
 Thank you, but I already changed this per the stackflow post, and I am 
 still getting the error.  I will keep searching.
 D


 On Saturday, August 23, 2014 5:47:08 PM UTC-4, Dallas wrote:

 does anyone know how this should be 

 ?php e($html-image('index_01.jpg'));?/td

 and 
?php e($html-css('shark')); ?

 shark being my stylesheet.  when I removed the above css line, my 
 background came up.  So I do not know if I no longer need these lines or 
 if 
 the language has changed. They were calling for undefined functions in 
 the 
 error messages.

 Thanks for any help

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




 -- 
 Kind Regards
  Stephen Speakman
  



 -- 
 Kind Regards
  Stephen Speakman
  


-- 
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: How to get controller name from an element view?

2014-08-28 Thread Jipson Thomas
Hi ,
I tried this solution to get controller name on my layout file, but I am 
getting an error on CakePHP3 as follows,
*Error: * *paramsHelper* could not be found. 
IS there anyone know a proper solution for this?

Regards,
Jipson

On Friday, 8 February 2008 19:30:35 UTC, Guill3rmo wrote:

 Hi im newbie and my English still sucks, but i want to know get the 
 controller name since an element view. Thanks. 


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


Get controller name on layout file - CakePHP3

2014-08-28 Thread Jipson Thomas
Hi,
In my Cakephp 3 project on the layout file, I want to set menu classes 
based on the current controller name. After a search I tried to get it 
through the following command on my layout.ctp file
?php echo $this-params['controller']; ?

But it throughs me an error as following
*Error: * *paramsHelper* could not be found. 
*Error: * Create the class *paramsHelper* below in file: 
src/View/Helper/paramsHelper.php

Does anyone know any fix for this?

Regards,
Jipson

-- 
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: How to get controller name from an element view?

2014-08-28 Thread Stephen S
I don't think you can use the request object from within an element, but
here's the documentation on it.
http://book.cakephp.org/3.0/en/controllers/request-response.html#request-parameters

If you can't access it from the element you can save it as a variable in
your AppController, though this isn't ideal I understand. Hopefully
somebody else can chip in and provide a better method


On 28 August 2014 13:32, Jipson Thomas jip...@strategic-ic.co.uk wrote:

 Hi ,
 I tried this solution to get controller name on my layout file, but I am
 getting an error on CakePHP3 as follows,
 *Error: * *paramsHelper* could not be found.
 IS there anyone know a proper solution for this?

 Regards,
 Jipson

 On Friday, 8 February 2008 19:30:35 UTC, Guill3rmo wrote:

 Hi im newbie and my English still sucks, but i want to know get the
 controller name since an element view. Thanks.

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




-- 
Kind Regards
 Stephen Speakman

-- 
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: Get controller name on layout file - CakePHP3

2014-08-28 Thread Thomas von Hassel
you have to look in `$this-request` instead


On 28 Aug 2014, at 14:35, Jipson Thomas jip...@strategic-ic.co.uk wrote:

 Hi,
 In my Cakephp 3 project on the layout file, I want to set menu classes based 
 on the current controller name. After a search I tried to get it through the 
 following command on my layout.ctp file
 ?php echo $this-params['controller']; ?
 
 But it throughs me an error as following
 Error: paramsHelper could not be found.   
 Error: Create the class paramsHelper below in file: 
 src/View/Helper/paramsHelper.php
 
 Does anyone know any fix for this?
 
 Regards,
 Jipson
 
 
 -- 
 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: How to get controller name from an element view?

2014-08-28 Thread Jipson Thomas
Thank you. I got it working by the following command.
$this-request-params['controller']
Thanks,
Jipson

On Friday, 8 February 2008 19:30:35 UTC, Guill3rmo wrote:

 Hi im newbie and my English still sucks, but i want to know get the 
 controller name since an element view. Thanks. 


-- 
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: Get controller name on layout file - CakePHP3

2014-08-28 Thread Jipson Thomas
Thank you very much. I got it working using the following command
$this-request-params['controller']

Regards,
Jipson

On Thursday, 28 August 2014 13:42:54 UTC+1, Thomas von Hassel wrote:

 you have to look in `$this-request` instead


 On 28 Aug 2014, at 14:35, Jipson Thomas jip...@strategic-ic.co.uk 
 javascript: wrote:

 Hi,
 In my Cakephp 3 project on the layout file, I want to set menu classes 
 based on the current controller name. After a search I tried to get it 
 through the following command on my layout.ctp file
 ?php echo $this-params['controller']; ?

 But it throughs me an error as following
 *Error: * *paramsHelper* could not be found. 
 *Error: * Create the class *paramsHelper* below in file: 
 src/View/Helper/paramsHelper.php

 Does anyone know any fix for this?

 Regards,
 Jipson


 -- 
 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 javascript:.
 To post to this group, send email to cake...@googlegroups.com 
 javascript:.
 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.


Paginate Sort on columns from related tables

2014-08-28 Thread John Sposato
We are having some issues getting this to work, is it possible?

For example,

We have a Patient model with a HABTM relationship to CareGiver.  And a 
PatientCase model that belongs to Patient with the hasMany to it from 
Patient.  Both HABTM relationships are setup and are correct.  

On the patient_cases index, we are trying to sort on some CareGiver 
columns, but it's not working.  It seems to sort, but not by those columns. 
 Is going from PatientCase-Patient-CareGiver too far for Paginate to sort 
columns?

-- 
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: migration issue

2014-08-28 Thread 'Dallas' via CakePHP
I am going to try this - I have been avoiding it because I host my site on 
a shared server and I do not know how to use the console to bake the shells 
or anything else.  So I will go back to youtube to watch how to videos. 
 Any advice would be welcome - I am sure it is not hard - I am just a total 
virgin.
Thanks
D

On Thursday, August 28, 2014 2:25:17 AM UTC-4, Dakota wrote:

 Hi Dallas,

 Have you tried running the CakePHP 2 upgrade shell?


 http://book.cakephp.org/2.0/en/console-and-shells/upgrade-shell.html#upgrade-shell

 It does about 90% of the grunt work for you, renames directories, moves 
 files, search and replace things like $html to $this-Html, etc.

 On Thursday, 28 August 2014 02:25:13 UTC+2, Dallas wrote:

 one other thing Stephan, following a migration tutorial I didn't transfer 
 the old index.php from app/webroot/index.php - i kept the 2.5.3 clean 
 version.  Should I be bringing over code from the earlier version and addi 
 to 2.5.3 cake or just use the old version.  I am getting another error 
 regarding the dispatcher request response on that file?  Thank you for all 
 of your help. I am determined to get this back up.
 D

 On Tuesday, August 26, 2014 2:50:44 PM UTC-4, Stephen S wrote:

 Also your index method is outside of your class, is this deliberate? 


 On 26 August 2014 19:48, Stephen S hellos...@gmail.com wrote:

 It doesn't look like you're using the request handler in this 
 controller or the construct method, why not remove both? CakePHP 2.x 
 controllers don't really need to use construct, beforeFilter is usually 
 more than sufficient.

 Hope this helps


 On 26 August 2014 17:31, 'Dallas' via CakePHP cake...@googlegroups.com
  wrote:

 Andras,
 Thank you, but I already changed this per the stackflow post, and I am 
 still getting the error.  I will keep searching.
 D


 On Saturday, August 23, 2014 5:47:08 PM UTC-4, Dallas wrote:

 does anyone know how this should be 

 ?php e($html-image('index_01.jpg'));?/td

 and 
?php e($html-css('shark')); ?

 shark being my stylesheet.  when I removed the above css line, my 
 background came up.  So I do not know if I no longer need these lines or 
 if 
 the language has changed. They were calling for undefined functions in 
 the 
 error messages.

 Thanks for any help

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




 -- 
 Kind Regards
  Stephen Speakman
  



 -- 
 Kind Regards
  Stephen Speakman
  


-- 
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: TranslateBehavior clarification

2014-08-28 Thread Thomas von Hassel
Hey

Sorry to bump this, but is there a verdict from the powers that be ? ;)

/thomas


On 27 Aug 2014, at 16:53, José Lorenzo jose@gmail.com wrote:

 What happens if you try to select a few fields?
 
 On Wednesday, August 27, 2014 3:05:28 PM UTC+2, Thomas von Hassel wrote:
 Hey 
 
 In 2.x when you used translate, the table should not contain the field(s) 
 that you were translating. 
 
 In 3.x it's not clear if this is still the case or if the table should have 
 the fields that you are trying to translate. For instance, when the table has 
 a translated field `name`, using find('list')-select(['id', 'name']) fails, 
 but setting the locale and doing a find('all') correctly output the 
 translated fields. 
 
 
 
 /thomas 
 
 
 
 -- 
 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: Basic data fetching

2014-08-28 Thread Tristan Plumley
Thanks for the reply. 

I was actually doing your second example until i decided to build an array 
manually. The reason was if i just send the entire customer info using 
find('first') with no recursive, i would get all the data i needed for the 
form in 1 set(). Is it good practice to send more than 1 set if it can be 
avoided or it just doesnt matter?



On Wednesday, 27 August 2014 16:47:33 UTC-4, Andras Kende wrote:

 Try something like 

 $this-set(‘customer info’,$this-Customer-find(‘first’,array(‘recursive’ 
 = -1, ‘conditions’ = array(‘id’=$customerId; 
 adding ‘recursive’ = -1 will only get the customer data.. 

 to get e select list for a customer devices 
 $this-set(‘customer 
 info’,$this-Customer-Device-find(‘list’,array(‘conditions’ = 
 array(‘customer_id’=$customerId; 

 http://book.cakephp.org/2.0/en/models/retrieving-your-data.html 

 Andras Kende 


 On Aug 27, 2014, at 12:25 PM, Tristan Plumley plumley...@gmail.com 
 javascript: wrote: 

  Hello, I'm fairly new to cakephp and have a few pretty basic questions 
 about fetching data from arrays: 
  
  here is what i have set up 
  
  Models: 
  
  class Customer extends AppModel { 
  
  
   public $hasMany = array('Device','Change'); 

  } 
  
  class Device extends AppModel { 
  
  
   public $belongsTo = 'Customer'; 
  } 
  
  
  class Change extends AppModel { 
  
  
   public $belongsTo = 'Customer'; 
  } 
  
  
  now anytime I 
  
 $this-set('customerinfo',$this-Customer-find('first',array('conditions' 
 = array('id'=$customerId; 
  
  or find('all'), i get everything on that customer, including all devices 
 and all thousands of changes. 
  
  One of my questions is how should i manage that relationship since i 
 dont want to pull that much change data just to get a customer ID, name and 
 address? 
  
  Have I built my model relationships too simple to allow for me for 
 limiting what is being sent? 
  
  
  question #2 
  
  doing the above statement, i get the following returned: 
  
  
  array( 
  'Customer' = array( 
  'id' = '33', 
  'name' = 'customer#33', 
  'totchngavail' = '5', 
  'totalchanges' = '0' 
  ), 
  'Device' = array( 
  (int) 0 = array( 
  'id' = '6', 
  'customer_id' = '33', 
  'name' = 'device4', 
  'type' = 'server', 
  'os' = 'aix', 
  'ip' = '123.123.123.123' 
  ), 
  (int) 1 = array( 
  'id' = '31', 
  'customer_id' = '33', 
  'name' = 'dev2', 
  'type' = 'server', 
  'os' = 'linux', 
  'ip' = '123.123.123.123' 
  ) 
  ), 
  'Change' = array( 
  (int) 0 = array( 
  'id' = '2', 
  'customer_id' = '33', 
  'name' = 'change12', 
  'number' = '1234567890' 
  ), 
  (int) 1 = array( 
  'id' = '4', 
  'customer_id' = '33', 
  'name' = 'change14', 
  'number' = '1234567890' 
  ) 
  
   ///many many more changes 
  ) 
  ) 
  
  
  
  When i try and retrieve all the devices for that customer in a select 
 box for example i try with: 
  
  echo $this-Form-input('device_id',array('label'= 'Device 
 Name','style' = 'width: 150px;','type' = 'select', 
  'options' = displayDevices($customerinfo))); 
  
  and here is the displayDevices function: 
  
  function displayDevices($customerinfo){ 
  //a list 'header' so no device is selected by default 
   $var =array(NULL='---'); 
   foreach($customerinfo['Device'] as $device) 
   { 
   $var+=array($device['id']=$device['name']); 
   } 
   return $var; 
  }; 
  
  
  So my question is: shouldnt there be a better way of displaying that 
 select list? maybe by some form of $customerinfo['Device']['name'] right 
 into the form input? When i do this i get an index error. I dont see how i 
 should have to manually build an array to populate the select list when the 
 complete customer array with devices comes in from the controller. 
  
  
  thanks in advance for your advice. 
  
  
  -- 
  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 javascript:. 
  To post to this group, send email to cake...@googlegroups.com 
 javascript:. 
  Visit this group at 

Re: Basic data fetching

2014-08-28 Thread Andras Kende
In my opinion:
- 1 set() or 2 set() doesn't matter.
- Doing a manual foreach to create an array for devices list seems to be going 
against the framework, if there builtin 1 liner for it ..
- also the check your sql_dump debug output of queries, on my example there 
should be 2 very simple sql like select * from user id = X and select * rom 
devices where user_id = X
if you don't use containable you could be fetching unnecessary data from 
changes table for example.

controller:
$this-set('devices',$this-Customer-Device-find('list',array('conditions' = 
array('customer_id'=$customerId;

view:
?php echo $this-Form-input('device_id', array('empty' = '-')); ?

Andras Kende


On Aug 28, 2014, at 6:36 AM, Tristan Plumley plumleytris...@gmail.com wrote:

 Thanks for the reply. 
 
 I was actually doing your second example until i decided to build an array 
 manually. The reason was if i just send the entire customer info using 
 find('first') with no recursive, i would get all the data i needed for the 
 form in 1 set(). Is it good practice to send more than 1 set if it can be 
 avoided or it just doesnt matter?
 
 
 
 On Wednesday, 27 August 2014 16:47:33 UTC-4, Andras Kende wrote:
 Try something like 
 
 $this-set('customer info',$this-Customer-find('first',array('recursive' = 
 -1, 'conditions' = array('id'=$customerId; 
 adding 'recursive' = -1 will only get the customer data.. 
 
 to get e select list for a customer devices 
 $this-set('customer 
 info',$this-Customer-Device-find('list',array('conditions' = 
 array('customer_id'=$customerId; 
 
 http://book.cakephp.org/2.0/en/models/retrieving-your-data.html 
 
 Andras Kende 
 
 
 On Aug 27, 2014, at 12:25 PM, Tristan Plumley plumley...@gmail.com wrote: 
 
  Hello, I'm fairly new to cakephp and have a few pretty basic questions 
  about fetching data from arrays: 
  
  here is what i have set up 
  
  Models: 
  
  class Customer extends AppModel { 
  
  
   public $hasMany = array('Device','Change'); 

  } 
  
  class Device extends AppModel { 
  
  
   public $belongsTo = 'Customer'; 
  } 
  
  
  class Change extends AppModel { 
  
  
   public $belongsTo = 'Customer'; 
  } 
  
  
  now anytime I 
  $this-set('customerinfo',$this-Customer-find('first',array('conditions' 
  = array('id'=$customerId; 
  
  or find('all'), i get everything on that customer, including all devices 
  and all thousands of changes. 
  
  One of my questions is how should i manage that relationship since i dont 
  want to pull that much change data just to get a customer ID, name and 
  address? 
  
  Have I built my model relationships too simple to allow for me for limiting 
  what is being sent? 
  
  
  question #2 
  
  doing the above statement, i get the following returned: 
  
  
  array( 
  'Customer' = array( 
  'id' = '33', 
  'name' = 'customer#33', 
  'totchngavail' = '5', 
  'totalchanges' = '0' 
  ), 
  'Device' = array( 
  (int) 0 = array( 
  'id' = '6', 
  'customer_id' = '33', 
  'name' = 'device4', 
  'type' = 'server', 
  'os' = 'aix', 
  'ip' = '123.123.123.123' 
  ), 
  (int) 1 = array( 
  'id' = '31', 
  'customer_id' = '33', 
  'name' = 'dev2', 
  'type' = 'server', 
  'os' = 'linux', 
  'ip' = '123.123.123.123' 
  ) 
  ), 
  'Change' = array( 
  (int) 0 = array( 
  'id' = '2', 
  'customer_id' = '33', 
  'name' = 'change12', 
  'number' = '1234567890' 
  ), 
  (int) 1 = array( 
  'id' = '4', 
  'customer_id' = '33', 
  'name' = 'change14', 
  'number' = '1234567890' 
  ) 
  
   ///many many more changes 
  ) 
  ) 
  
  
  
  When i try and retrieve all the devices for that customer in a select box 
  for example i try with: 
  
  echo $this-Form-input('device_id',array('label'= 'Device Name','style' 
  = 'width: 150px;','type' = 'select', 
  'options' = displayDevices($customerinfo))); 
  
  and here is the displayDevices function: 
  
  function displayDevices($customerinfo){ 
  //a list 'header' so no device is selected by default 
   $var =array(NULL='---'); 
   foreach($customerinfo['Device'] as $device) 
   { 
   $var+=array($device['id']=$device['name']); 
   } 
   return $var; 
  }; 
  
  
  So my question is: shouldnt there be a better way of displaying that select 
  list? maybe by some form of