Re: how to display a different field name from the database in the model

2008-10-05 Thread the_woodsman

I'm pretty sure someone wrote a behavior to handle this, perhaps the
Alias behaviour? Look in the bakery...

On Oct 5, 7:42 am, "David C. Zentgraf" <[EMAIL PROTECTED]> wrote:
> You should really look into changing the variable name in the code.  
> With search&replace this may be the best option.
>
> Otherwise, you could do that in the model with the afterFind callback.
> Just copy the field:
> $model['name'] = $model['name_en_gb'];
>
> But you're setting yourself up for all kinds of problems with this, as  
> you'll have to convert back and forth between the database and  
> application.
>
> On 5 Oct 2008, at 15:36, robert123 wrote:
>
>
>
> > hi,
>
> > Thank you, I have a cakephp application, the product model has the
> > 'name' field, and all the codes, that is the controller, view, call
> > that field as 'name'.
>
> > but right now the product table in the database which has the field
> > 'name' has been changed to 'name_en_gb', I am wondering, is there any
> > small change in the model I can do such that it will read the
> > 'name_en_gb' field in the product table in the database, but at the
> > code level, the view, controller, etc can access it using the 'name'
> > field.
>
> > Thank you
>
> > On Oct 5, 2:21 pm, "David C. Zentgraf" <[EMAIL PROTECTED]> wrote:
> >> If you mean "display to the user" I don't see where the problem is.
> >> If you're talking about scaffolding, just make a proper view.
> >> If you mean "change internally" it's more hassle than it's worth  
> >> IMHO.
>
> >> Can you clarify a bit what you want to do and where you're stuck?
>
> >> On 5 Oct 2008, at 10:32, robert123 wrote:
>
> >>> hi
>
> >>> in my database there is a field
>
> >>> which is name_en_gb
>
> >>> in my model
>
> >>> i wanted it to read the field, but display it as the field
>
> >>> name
>
> >>> can anyone let me know how to do it, thank you
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: how to display a different field name from the database in the model

2008-10-04 Thread David C. Zentgraf

You should really look into changing the variable name in the code.  
With search&replace this may be the best option.

Otherwise, you could do that in the model with the afterFind callback.
Just copy the field:
$model['name'] = $model['name_en_gb'];

But you're setting yourself up for all kinds of problems with this, as  
you'll have to convert back and forth between the database and  
application.

On 5 Oct 2008, at 15:36, robert123 wrote:

>
> hi,
>
> Thank you, I have a cakephp application, the product model has the
> 'name' field, and all the codes, that is the controller, view, call
> that field as 'name'.
>
> but right now the product table in the database which has the field
> 'name' has been changed to 'name_en_gb', I am wondering, is there any
> small change in the model I can do such that it will read the
> 'name_en_gb' field in the product table in the database, but at the
> code level, the view, controller, etc can access it using the 'name'
> field.
>
> Thank you
>
> On Oct 5, 2:21 pm, "David C. Zentgraf" <[EMAIL PROTECTED]> wrote:
>> If you mean "display to the user" I don't see where the problem is.
>> If you're talking about scaffolding, just make a proper view.
>> If you mean "change internally" it's more hassle than it's worth  
>> IMHO.
>>
>> Can you clarify a bit what you want to do and where you're stuck?
>>
>> On 5 Oct 2008, at 10:32, robert123 wrote:
>>
>>
>>
>>> hi
>>
>>> in my database there is a field
>>
>>> which is name_en_gb
>>
>>> in my model
>>
>>> i wanted it to read the field, but display it as the field
>>
>>> name
>>
>>> can anyone let me know how to do it, thank you
> >


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



Re: how to display a different field name from the database in the model

2008-10-04 Thread robert123

hi,

Thank you, I have a cakephp application, the product model has the
'name' field, and all the codes, that is the controller, view, call
that field as 'name'.

but right now the product table in the database which has the field
'name' has been changed to 'name_en_gb', I am wondering, is there any
small change in the model I can do such that it will read the
'name_en_gb' field in the product table in the database, but at the
code level, the view, controller, etc can access it using the 'name'
field.

Thank you

On Oct 5, 2:21 pm, "David C. Zentgraf" <[EMAIL PROTECTED]> wrote:
> If you mean "display to the user" I don't see where the problem is.
> If you're talking about scaffolding, just make a proper view.
> If you mean "change internally" it's more hassle than it's worth IMHO.
>
> Can you clarify a bit what you want to do and where you're stuck?
>
> On 5 Oct 2008, at 10:32, robert123 wrote:
>
>
>
> > hi
>
> > in my database there is a field
>
> > which is name_en_gb
>
> > in my model
>
> > i wanted it to read the field, but display it as the field
>
> > name
>
> > can anyone let me know how to do it, thank you
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: how to display a different field name from the database in the model

2008-10-04 Thread David C. Zentgraf

If you mean "display to the user" I don't see where the problem is.
If you're talking about scaffolding, just make a proper view.
If you mean "change internally" it's more hassle than it's worth IMHO.

Can you clarify a bit what you want to do and where you're stuck?

On 5 Oct 2008, at 10:32, robert123 wrote:

>
> hi
>
> in my database there is a field
>
> which is name_en_gb
>
> in my model
>
> i wanted it to read the field, but display it as the field
>
> name
>
>
> can anyone let me know how to do it, thank you
>
>
>
> >


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



Re: how to display a different field name from the database in the model

2008-10-04 Thread Christian Leskowsky

This should be taken care of by your view.

You'd do something like this in your form:

input('name_en_gb', array('label' => __('name', true))); 
?>

Good Luck!
Christian

- Original Message - 
From: "robert123" <[EMAIL PROTECTED]>
To: "CakePHP" 
Sent: Saturday, October 04, 2008 9:32 PM
Subject: how to display a different field name from the database in the 
model


>
> hi
>
> in my database there is a field
>
> which is name_en_gb
>
> in my model
>
> i wanted it to read the field, but display it as the field
>
> name
>
>
> can anyone let me know how to do it, thank you
>
>
>
> > 


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



how to display a different field name from the database in the model

2008-10-04 Thread robert123

hi

in my database there is a field

which is name_en_gb

in my model

i wanted it to read the field, but display it as the field

name


can anyone let me know how to do it, thank you



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