Re: displaying sql query

2010-06-04 Thread Toby Ashley
You never return $result from the getResult function. You need:

function getResult()
{

  $result = $this->query("SELECT * FROM `downloads` WHERE `index`=123");
  return $result;

 }



On Fri, Jun 4, 2010 at 10:40 AM, ytbryan  wrote:

> Hi all,
>
> Can someone help me with this.
>
> I do a query on my database from model.
>
> function getResult()
> {
>
> $result = $this->query("SELECT * FROM `downloads`
> WHERE
> `index`=123");
>
>}
>
> I call assign the query result to the view from controller.
>
> function index(){
>$this->set('result', $this->MosDownload->getResult());
> }
>
> I call the variable on the view.
>
>
>
>
>
> But the result is not displayed. What is wrong ?
>
> 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.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

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

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


HABTM - retrieve items from ModelA that *are not* linked to a particular item from ModelB

2009-10-29 Thread Toby Ashley
Hello all,

Assuming two hypothetical models, Post and Tag, joined with a HABTM
relationship, of course it's trivial to retrieve a list of all Posts which
are linked to a particular Tag.

However, if I wanted to retrieve a list of all Posts which *are not* linked
to a particular Tag, what would be the best approach?

Of course, I could first retrieve a list of all Posts, then retrieve a list
of Posts linked to the Tag, and then manually iterate through the array
'removing' one from the other, but is there a better way?

Grateful for any suggestions.

Cheers,
toby

--~--~-~--~~~---~--~~
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: Parse error in Model.

2009-10-28 Thread Toby Ashley
 This...

 function validatePassword(password1 = null, password2 = null) {

...should be

   function validatePassword($password1 = null, $password2 = null) {



On Wed, Oct 28, 2009 at 10:59 PM, centr0  wrote:

>
> For the life of me i cant figure out why im getting a parse error.
>
>  class User extends AppModel {
>var $name = 'User';
>var $belongsTo = array('Group');
>var $validate = array(
>'email' => array(
>'rule' => 'email',
>'message' => 'Email address is required.'
>),
>'password' => array(
>'rule' => 'alphaNumeric',
>'required' => true,
>'message' => 'Password is required.'
>),
>'confirm_password' => array(
>'rule' => 'alphaNumeric',
>'required' => true,
>'message' => 'Password is required.'
>)
>);
>
>
>function validatePassword(password1 = null, password2 = null) {
>}
> }
> ?>
>
> it happens when i add args to the validatePassword().  if they don't
> have args  it runs fine.  any ideas?  am i crazy?
> >
>

--~--~-~--~~~---~--~~
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: find __() function parameters in /app and update *.po - automated

2009-10-14 Thread Toby Ashley
I am using this system mainly for translations, yes. The site runs in 12
languages, and currently contains over 250 ctp files.

However, an added benefit of the l18n system for me is that the
administrator can also make adjustments to the text on the English site, not
just the translated languages. It's far more convenient for me to create a
string with msgid registrationCompleteMessage and allow them to edit that
message themselves in *all* languages, not just the non-English languages.
As we all know, it's a pain when a client endlessly sends through text
amends, and this system allows them to have full control of the content of
their own site.

However, my question wasn't concerning the use of slugs vs full strings - I
can see the pros and cons for each method. My question was about a system
for enabling these translations to be managed through an administration area
of a site, and what methods people are using to do that? My admin users
can't be trusted to have direct access to the *.po files, so I created the
CSV export / import system to allow them to edit the translations safely,
giving me time to validate their translations without ever giving them
direct access to the locales directory. This all works great for my needs,
but I'm wondering if there are any other recommended approaches for this?

Cheers,
toby


On Wed, Oct 14, 2009 at 5:56 PM, Larry E. Masters aka PhpNut <
php...@gmail.com> wrote:

> Toby,
> It sounds like you are trying to use translations as a way to also change
> text.
>
> Examples (forgive me in advance if google did not translate these
> properly):
>
> "Welcome to the home page of CakePHP the best PHP framework for rapidly
> building applications."
>
> Translated to German this would be:
>
> "Willkommen auf der Homepage von CakePHP den besten Rahmen für PHP schnell
> die Erstellung von Anwendungen."
>
> Anything else would not be a translation:
>
> Example:
>
> "Herzlich Willkommen auf meiner Homepage der Anwendungen habe ich mit Hilfe
> meiner CakePHP Rahmen der Wahl."
>
> Which means:
>
> "Welcome to my home page of the applications I have built using CakePHP my
> framework of choice."
>
> This is not translating text, and it not what I18n is to be used for.
>
> --
> /**
> * @author Larry E. Masters
> * @var string $userName
> * @param string $realName
> * @returns string aka PhpNut
> * @access  public
> */
>
> On Wed, Oct 14, 2009 at 9:15 AM, Toby Ashley  wrote:
>
>> While this discussion is going on, I thought I'd raise / ask something...
>>
>> In a recent project, I needed to make it easy for administrators to be
>> able to edit the text used throughout the site. The site itself runs in 12
>> languages, and as a result I have 12 *.po files, one per territory. The
>> administrators for each language are fairly non-technical, and so the system
>> needed to be easy.
>>
>> I built a simple system which would do the following:
>>
>> -- Provide a 'download existing website text' button to the administrator
>> - the controller action would then read through the appropriate *.po file
>> and generate a CSV with two columns, the identifier (i'm also using
>> descriptive slugs, as mentioned by Miles) and the current string for that
>> identifier
>>
>> -- The administrator can then make the necessary amendments before
>> re-importing the CSV. When re-importing, the system backs up the existing
>> *.po file and creates a new one, manually writing the msgid and msgstr
>> values from the data in the CSV. Finally, when this is done, the system
>> removes any relevant cache files and  hey presto - the website text is
>> updated.
>>
>> -- There's also tools to revert to previous backup, in case they make an
>> almighty mess of everything.
>>
>> This system worked fine for the project, and the administrators of the
>> site are maintaining the different languages with success, but I'm wondering
>> if there's a better / simpler / more recommend way of achieving the same
>> functionality. I guess it's kind of like a friendly, web-based interface for
>> editing these *.po files
>>
>> Any suggestions?
>>
>> Cheers,
>> toby
>>
>>
>>
>>
>> On Wed, Oct 14, 2009 at 2:05 AM, Larry E. Masters aka PhpNut <
>> php...@gmail.com> wrote:
>>
>>> Cool, let me know if you have any questions.
>>> --
>>> /**
>>> * @author Larry E. Masters
>>> * @var string $userName
>>> * @param string $realName
>>> * @returns string aka PhpNut
>>> * @access  public
>&

Re: find __() function parameters in /app and update *.po - automated

2009-10-14 Thread Toby Ashley
While this discussion is going on, I thought I'd raise / ask something...

In a recent project, I needed to make it easy for administrators to be able
to edit the text used throughout the site. The site itself runs in 12
languages, and as a result I have 12 *.po files, one per territory. The
administrators for each language are fairly non-technical, and so the system
needed to be easy.

I built a simple system which would do the following:

-- Provide a 'download existing website text' button to the administrator -
the controller action would then read through the appropriate *.po file and
generate a CSV with two columns, the identifier (i'm also using descriptive
slugs, as mentioned by Miles) and the current string for that identifier

-- The administrator can then make the necessary amendments before
re-importing the CSV. When re-importing, the system backs up the existing
*.po file and creates a new one, manually writing the msgid and msgstr
values from the data in the CSV. Finally, when this is done, the system
removes any relevant cache files and  hey presto - the website text is
updated.

-- There's also tools to revert to previous backup, in case they make an
almighty mess of everything.

This system worked fine for the project, and the administrators of the site
are maintaining the different languages with success, but I'm wondering if
there's a better / simpler / more recommend way of achieving the same
functionality. I guess it's kind of like a friendly, web-based interface for
editing these *.po files

Any suggestions?

Cheers,
toby



On Wed, Oct 14, 2009 at 2:05 AM, Larry E. Masters aka PhpNut <
php...@gmail.com> wrote:

> Cool, let me know if you have any questions.
> --
> /**
> * @author Larry E. Masters
> * @var string $userName
> * @param string $realName
> * @returns string aka PhpNut
> * @access  public
> */
>
> On Tue, Oct 13, 2009 at 7:46 PM, Miles J  wrote:
>
>>
>> Well see now a lot of it makes sense. The guide is pretty vague on
>> i18n/l10n and how it works / is used.
>>
>> Will give this a try.
>>
>> On Oct 13, 5:39 pm, "Larry E. Masters aka PhpNut" 
>> wrote:
>> > Incorrect, the file that is created using the i18n extract creates a
>> .pot
>> > file which is a template file and can be opened in any po editor or text
>> > editor. The template is not language specific. There is no reason to
>> create
>> > these files by hand. Write your code and output using the sentences you
>> > would normally use just wrap the string in __() function. Run the
>> extractor
>> > and you are done.
>> > Easiest tool to edit translations I have recently found is
>> poedit.www.poedit.net
>> >
>> > I uploaded current core extracted pot file.
>> >
>> > http://cake-php.googlegroups.com/web/default.pot
>> >
>> > Download it and open in poedit.
>> >
>> > The nice thing about these pot file is you can create a new version with
>> > changes in your application, reopen the template in poedit, and it will
>> > merge changes highlighting the strings that have changed.
>> >
>> > Not sure if you are aware how the other translation functions work in
>> the
>> > core, but when it comes to handling plurals in a sentence, your slugs
>> will
>> > become more confusing.
>> >
>> > for($number = 0; $i < 100; $number++) {
>> > sprintf(__n('There is %d apple in the fruit bowl', 'There are %d apples
>> in
>> > the fruit bowl', $number), $number);
>> >
>> > }
>> >
>> > msgid "There is %d apple in the fruit bowl"
>> > msgid_plural "There are %d apples in the fruit bowl"
>> > msgstr[0] ""
>> > msgstr[1] ""
>> > msgstr[2] ""
>> > msgstr[3] ""
>> > msgstr[4] ""
>> > msgstr[5] ""
>> > msgstr[6] ""
>> >
>> > There are 16 plural rules that range from 1 form of plural to 6 forms of
>> > plural depending on the value of $number. It all depends and the
>> language
>> > the content is being translated to. The above example be based on the
>> header
>> > in the po file, which poedit allows you to set based on the language you
>> are
>> > using.
>> >
>> > Only 1 form of plural.
>> > "Plural-Forms: nplurals=1; plural=0;\n"
>> >
>> > 6 forms of plural.
>> > "Plural-Forms: nplurals=4; plural=n==1 ? 0 : n==2 ? 1 : n==0 || (n>=3 &&
>> > n<=10) ? 2 : 3;\n"
>> >
>> > 14 other forms or plural are available. These will be added to the
>> > translation site I had online for the project before. This will be
>> coming
>> > back online in the next few weeks. They will also be added to the book,
>> with
>> > corrections on the proper use of these functions soon. If you need the
>> > correct plural form before then, let me know and I can reply with it.
>> >
>> > --
>> > /**
>> > * @author Larry E. Masters
>> > * @var string $userName
>> > * @param string $realName
>> > * @returns string aka PhpNut
>> > * @access  public
>> > */
>> >
>> > On Tue, Oct 13, 2009 at 6:50 PM, Miles J 
>> wrote:
>> >
>> > > But you would need to make the english po file anyways if you are
>> > > going to distribute it and have it translated.
>> >
>> > > On Oct 13, 12:58 pm, "

HABTM with extra field - view setup question

2009-06-05 Thread Toby Ashley
Hi chaps,

I have a relationship -  User HABTM Organisation - and I have an extra field
'account_number' in my join table.

On my user registration form, I need to it display a corresponding checkbox
and text input for each organisation that exists in the database. If the
user ticks the checkbox for a given organisation to state that they're a
member of that organisation, the text input becomes enabled, allowing them
to enter their account number.

Obviously, if I didnt have this extra field and only needed the checkboxes,
this would be fairly automatic using 'multiple'=>'checkbox', but I'm
wondering if there's a CakePHP-friendly way of achieving what I want with
this extra field / input. Of course, I could assemble the form manually and
reassemble the info from $this->data in my controller to get it into the
correct format for the save, but I'm wondering if there's an easier way of
doing what I need Any suggestions on a decent approach for this?

Cheers!
Toby

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