Re: Dynamic Model Call

2009-01-21 Thread Webweave

OK, I'm not sure why you are trying to do the late binding and use a
variable model name, but my guess would be that there is something
that hasn't been set up in the normal Cake magic of loading the code
that has caused something not to be initialized.

What is the rest of the stack for the error you are seeing (that
should show you where in the cake base classes the actual error is
happening)?

On Jan 21, 8:22 pm, Yusuf Widiyatmono  wrote:
> sorry it just a mark for the code line.
>
> Fatal error: Cannot access empty property in 
> {some_directories_path}\app\controllers\areas_controller.php on line **
>
> i mean that i got that message from this line
>
> $model_data = $this->AreaInfo->$model_name->find('list');    **
>
> 
> From: brian 
> To: cake-php@googlegroups.com
> Sent: Thursday, January 22, 2009 1:06:39 PM
> Subject: Re: Dynamic Model Call
>
> What is on line** (from the error msg)?
>
> On Wed, Jan 21, 2009 at 10:37 PM, Yusuf Widiyatmono  wrote:
> > the model is loaded...
> > see the print_r result, the model can retrieve some data,
> > but in the end the error still appear and make the further logic die
>
> > 
> > From: brian 
> > To: cake-php@googlegroups.com
> > Sent: Thursday, January 22, 2009 12:30:22 PM
> > Subject: Re: Dynamic Model Call
>
> > Are these models loaded?
>
> > On Wed, Jan 21, 2009 at 6:10 PM, Yusuf Widiyatmono  wrote:
> >> i did and it still shows me same errors...
>
> >> 
> >> From: brian 
> >> To: cake-php@googlegroups.com
> >> Sent: Thursday, January 22, 2009 2:49:31 AM
> >> Subject: Re: Dynamic Model Call
>
> >> Try $this->AreaInfo->{$model_name}->find(...)
>
> >> On Wed, Jan 21, 2009 at 12:33 AM, wmonou  wrote:
>
> >>> Helo there i am trying to call model from a variable
>
> >>> let say that i have a code is like this:
>
> >>>        // $model_name is a string
> >>>        // bind necessary model
> >>>        if(!empty($model_name)){
> >>>                $this->AreaInfo->bindModel(
> >>>                        array(
> >>>                                'belongsTo'=>array(
> >>>                                        $model_name => array(
> >>>                                                'className' =>
> >>> $model_name,
> >>>                                                'foreignKey' =>
> >>> 'reference_id'
> >>>                                                )
> >>>                                        )
> >>>                                )
> >>>                        );
> >>>                }
>
> >>>        $model_data = $this->AreaInfo->$model_name->find('list');    // **
> >>> this is my question
> >>>        print_r($model_data);
>
> >>> the $model_data variable now is not empty, but i got something like
> >>> this :
>
> >>> Array
> >>> (
> >>>    [1] => 1
> >>>    [2] => 2
> >>>    [3] => 3
> >>>    [4] => 4
> >>>    [5] => 5
> >>>    [6] => 6
> >>>    [7] => 7
> >>>    [8] => 8
> >>>    [9] => 9
> >>>    [10] => 10
> >>>    [11] => 11
> >>>    [12] => 12
> >>>    [13] => 13
> >>>    [14] => 14
> >>>    [15] => 15
> >>>    [16] => 16
> >>>    [17] => 17
> >>>    [18] => 18
> >>>    [19] => 19
> >>>    [20] => 20
> >>> )
>
> >>> Fatal error: Cannot access empty property in {some_directories_path}
> >>> \app\controllers\areas_controller.php on line **
>
> >>> is it possible to do such a thing like above? if yes or no please let
> >>> me know with your sugesstion :) ...
>
>
--~--~-~--~~~---~--~~
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: Several values in one form element

2009-01-21 Thread Jakob Malm

Figured it out when I woke up this morning...

input ( 'OrderRow.' . $ix . '.amount' ); ?>
hidden( 'OrderRow.' . $ix . '.product_id', array
( 'value' => $product['Product']['id'] ) ); ?>
hidden( 'OrderRow.' . $ix . '.size_id', array
( 'value' => $size['id'] ) ); ?>

$ix is the row number in the form, starting with 0.

/Jakob

On 22 Jan, 00:09, Jakob Malm  wrote:
> Hi,
>
> I have an order form, with a number of rows, one for each product and
> size. The user can type in a simple input field the number of products
> of that size he/she would like to order.
>
> The following models and relationships exist:
> Order, hasMany { OrderRow }
> OrderRow, hasOne { Product, Size } (+ a field called amount)
> Product, hasAndBelongsToMany { Size }
> Size, hasAndBelongsToMany { Product }
>
> How do I make form elements that include the id's of Product and Size
> of the specific row, and the amount, all included in the data
> correctly? In my mind, something like the following:
>
> $form->input ( 'OrderRow.product_id.size_id.antal' );
>
> and somehow populate the product_id and size_id fields with the
> correct values.
>
> I appreciate any help,Jakob
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Create html files dynamically

2009-01-21 Thread Sumesh G

hi

i am new in cakephp, please help me to solve this problem

my client wants to create html pages dynamically from the content they
submitted through admin section

For example;-
 if they add a job through admin section like ;- Software division  -
Application programming -php

we have to create an html file as software/ Application programming/
php/ jobId.html


thanks



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



Use Javascript to clean input

2009-01-21 Thread Mateo San Román

Hello

My application reads from a form input using an observeField function.
Now, when the in not valid, that input should be cleaned so the
following data could be validated correctly. Can anybody please give
me some steps on how to accomplish this kind of behavior?

Best Regards

--~--~-~--~~~---~--~~
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: Anyone built a forum system yet?

2009-01-21 Thread Brian Williams
not showing 100,000 threads?  I assumed that was a given...

My perception was that the OP was worried about processing power; for
example, on my VPS there is (among others) a single MySQL db that is over
280 megs, with 183 tables and over 2 million records and it runs without any
problems, of note there is a single table that has 1,640,537 records and it
doesn't affect the performance of the site or the server -- it's all about
the quality of your query that matters - not to mention indexes, and decent
maintenance.

You will never be loading all of the data rows at any one time, it just
won't happen.  I don't see how loading 1 row with 1k to 4k of data is worse
than loading potentially 10,000 records and processing them all.  Every
developer knows, or should know, that retrieving the data from the disk
takes longer than most computational processes.

so, you (the OP) wants the best performance/processing intensity resolution
with long term storage, the answer is still a db, just the logic and
formatting of the data is what you need to determine.

i recommend a serialized list of threads read and the date they were read --
no need to store threads that they haven't read yet.

just my 2 cents


On Thu, Jan 22, 2009 at 12:17 AM, brian  wrote:

>
> On Wed, Jan 21, 2009 at 11:41 PM, Jon Bennett  wrote:
> >
> > This shouldn't incur a massive DB hit, as even if you have 100,000
> > threads, you won't display 100,000 on one page!
>
> Yes. That's precisely the point that I think I should have pointed out
> many comments ago. I don't know if it's that misconception that is
> objectionable, or the notion that storing hundreds of thousands of
> data points at all is somehow an abuse of a good DB.
>
> >
>

--~--~-~--~~~---~--~~
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: Anyone built a forum system yet?

2009-01-21 Thread Miles J

Yes but if I understand that approach, for each thread in the system,
there would be a matching HABTM row as well... and that applies to
each user. Still just seems like a lot.
--~--~-~--~~~---~--~~
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: move_uploaded_file returns first letter of upload as error

2009-01-21 Thread mattman...@gmail.com

Solved! I forgot to make the form multipart/form-data. Thank you
anyway.

On Jan 21, 9:28 pm, "mattman...@gmail.com" 
wrote:
> Hello. I am currently working on a CMS for a client of mine, and am
> getting a weird error generated by move_uploaded_file: The first
> letter of the file I upload. Example:
>
> I upload a file called test.txt, and here is the error generated by
> move_upload_file:
>
> t
>
> This happens with all files I try. Here is the code that causes the
> error:
>
> if(!empty($this->data)) {
>         $tmp_name = $this->data['Upload']['file']['tmp_name'];
>         $upload_filename = Configure::read('StoragePath').basename($this->data
> ['Upload']['file']['name']);
>
>         if(move_uploaded_file($tmp_name, $upload_filename)) {
>            //this spot isn't reached, it stops at the
> move_uploaded_file above.
>        }
>
> Does anyone know what causes this problem and how I can fix it? Any
> input would be greatly appreciated.
--~--~-~--~~~---~--~~
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: Dynamic Model Call

2009-01-21 Thread brian

I don't think it's your english. I'm just confused that the find() can
fetch data, but also throw a fatal error, so I didn't understand the
question. Sorry, I don't think I can answer this.

Well, maybe if you change your code (after the bindModel() block) to:

Debugger::log($model_name);
$model_data = $this->AreaInfo->{$model_name}->find('list');
Debugger::log($model_data);

See what that outputs in the log, just as a sanity check.


On Thu, Jan 22, 2009 at 12:20 AM, Yusuf Widiyatmono  wrote:
> the error is happen because i use variable as model name
> $model_data = $this->AreaInfo->{$model_name}->find('list');
>
> but although its give me error and stop the php compile on that ** line
> its still could fetch data from that $model_name table..
> that is why the $model_data have value when i try to print it.
>
> my question is how to get rid this error?
>
> sorry for my bad english before :)
>
> 
> From: brian 
> To: cake-php@googlegroups.com
> Sent: Thursday, January 22, 2009 2:10:17 PM
> Subject: Re: Dynamic Model Call
>
>
> I don't think I understand what your question is, then. Yes, you can
> use a variable as the model name, if used the way I showed you. But,
> where did this error come from? If it was from the find() line, how is
> it that your array has data in it?
>
> On Wed, Jan 21, 2009 at 11:22 PM, Yusuf Widiyatmono 
> wrote:
>> sorry it just a mark for the code line.
>>
>> Fatal error: Cannot access empty property in
>> {some_directories_path}\app\controllers\areas_controller.php on line **
>>
>> i mean that i got that message from this line
>>
>> $model_data = $this->AreaInfo->$model_name->find('list');**
>>
>>
>>
>>
>>
>> 
>> From: brian 
>> To: cake-php@googlegroups.com
>> Sent: Thursday, January 22, 2009 1:06:39 PM
>> Subject: Re: Dynamic Model Call
>>
>>
>> What is on line** (from the error msg)?
>>
>> On Wed, Jan 21, 2009 at 10:37 PM, Yusuf Widiyatmono 
>> wrote:
>>> the model is loaded...
>>> see the print_r result, the model can retrieve some data,
>>> but in the end the error still appear and make the further logic die
>>>
>>>
>>>
>>> 
>>> From: brian 
>>> To: cake-php@googlegroups.com
>>> Sent: Thursday, January 22, 2009 12:30:22 PM
>>> Subject: Re: Dynamic Model Call
>>>
>>>
>>> Are these models loaded?
>>>
>>> On Wed, Jan 21, 2009 at 6:10 PM, Yusuf Widiyatmono 
>>> wrote:
 i did and it still shows me same errors...


 
 From: brian 
 To: cake-php@googlegroups.com
 Sent: Thursday, January 22, 2009 2:49:31 AM
 Subject: Re: Dynamic Model Call


 Try $this->AreaInfo->{$model_name}->find(...)

 On Wed, Jan 21, 2009 at 12:33 AM, wmonou  wrote:
>
> Helo there i am trying to call model from a variable
>
> let say that i have a code is like this:
>
>// $model_name is a string
>// bind necessary model
>if(!empty($model_name)){
>$this->AreaInfo->bindModel(
>array(
>'belongsTo'=>array(
>$model_name => array(
>'className' =>
> $model_name,
>'foreignKey' =>
> 'reference_id'
>)
>)
>)
>);
>}
>
>$model_data = $this->AreaInfo->$model_name->find('list');//
> **
> this is my question
>print_r($model_data);
>
> the $model_data variable now is not empty, but i got something like
> this :
>
> Array
> (
>[1] => 1
>[2] => 2
>[3] => 3
>[4] => 4
>[5] => 5
>[6] => 6
>[7] => 7
>[8] => 8
>[9] => 9
>[10] => 10
>[11] => 11
>[12] => 12
>[13] => 13
>[14] => 14
>[15] => 15
>[16] => 16
>[17] => 17
>[18] => 18
>[19] => 19
>[20] => 20
> )
>
> Fatal error: Cannot access empty property in {some_directories_path}
> \app\controllers\areas_controller.php on line **
>
> is it possible to do such a thing like above? if yes or no please let
> me know with your sugesstion :) ...
>
> >
>


 >

>>>
>>>
>>> >
>>>
>>
>>
>> >
>>
>
>
> >
>

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

move_uploaded_file returns first letter of upload as error

2009-01-21 Thread mattman...@gmail.com

Hello. I am currently working on a CMS for a client of mine, and am
getting a weird error generated by move_uploaded_file: The first
letter of the file I upload. Example:

I upload a file called test.txt, and here is the error generated by
move_upload_file:

t

This happens with all files I try. Here is the code that causes the
error:

if(!empty($this->data)) {
$tmp_name = $this->data['Upload']['file']['tmp_name'];
$upload_filename = Configure::read('StoragePath').basename($this->data
['Upload']['file']['name']);

if(move_uploaded_file($tmp_name, $upload_filename)) {
   //this spot isn't reached, it stops at the
move_uploaded_file above.
   }

Does anyone know what causes this problem and how I can fix it? Any
input would be greatly appreciated.
--~--~-~--~~~---~--~~
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: Dynamic Model Call

2009-01-21 Thread Yusuf Widiyatmono
the error is happen because i use variable as model name
$model_data = $this->AreaInfo->{$model_name}->find('list');

but although its give me error and stop the php compile on that ** line
its still could fetch data from that $model_name table..
that is why the $model_data have value when i try to print it.

my question is how to get rid this error?

sorry for my bad english before :)




From: brian 
To: cake-php@googlegroups.com
Sent: Thursday, January 22, 2009 2:10:17 PM
Subject: Re: Dynamic Model Call


I don't think I understand what your question is, then. Yes, you can
use a variable as the model name, if used the way I showed you. But,
where did this error come from? If it was from the find() line, how is
it that your array has data in it?

On Wed, Jan 21, 2009 at 11:22 PM, Yusuf Widiyatmono  wrote:
> sorry it just a mark for the code line.
>
> Fatal error: Cannot access empty property in
> {some_directories_path}\app\controllers\areas_controller.php on line **
>
> i mean that i got that message from this line
>
> $model_data = $this->AreaInfo->$model_name->find('list');**
>
>
>
>
>
> 
> From: brian 
> To: cake-php@googlegroups.com
> Sent: Thursday, January 22, 2009 1:06:39 PM
> Subject: Re: Dynamic Model Call
>
>
> What is on line** (from the error msg)?
>
> On Wed, Jan 21, 2009 at 10:37 PM, Yusuf Widiyatmono 
> wrote:
>> the model is loaded...
>> see the print_r result, the model can retrieve some data,
>> but in the end the error still appear and make the further logic die
>>
>>
>>
>> 
>> From: brian 
>> To: cake-php@googlegroups.com
>> Sent: Thursday, January 22, 2009 12:30:22 PM
>> Subject: Re: Dynamic Model Call
>>
>>
>> Are these models loaded?
>>
>> On Wed, Jan 21, 2009 at 6:10 PM, Yusuf Widiyatmono 
>> wrote:
>>> i did and it still shows me same errors...
>>>
>>>
>>> 
>>> From: brian 
>>> To: cake-php@googlegroups.com
>>> Sent: Thursday, January 22, 2009 2:49:31 AM
>>> Subject: Re: Dynamic Model Call
>>>
>>>
>>> Try $this->AreaInfo->{$model_name}->find(...)
>>>
>>> On Wed, Jan 21, 2009 at 12:33 AM, wmonou  wrote:

 Helo there i am trying to call model from a variable

 let say that i have a code is like this:

// $model_name is a string
// bind necessary model
if(!empty($model_name)){
$this->AreaInfo->bindModel(
array(
'belongsTo'=>array(
$model_name => array(
'className' =>
 $model_name,
'foreignKey' =>
 'reference_id'
)
)
)
);
}

$model_data = $this->AreaInfo->$model_name->find('list');//
 **
 this is my question
print_r($model_data);

 the $model_data variable now is not empty, but i got something like
 this :

 Array
 (
[1] => 1
[2] => 2
[3] => 3
[4] => 4
[5] => 5
[6] => 6
[7] => 7
[8] => 8
[9] => 9
[10] => 10
[11] => 11
[12] => 12
[13] => 13
[14] => 14
[15] => 15
[16] => 16
[17] => 17
[18] => 18
[19] => 19
[20] => 20
 )

 Fatal error: Cannot access empty property in {some_directories_path}
 \app\controllers\areas_controller.php on line **

 is it possible to do such a thing like above? if yes or no please let
 me know with your sugesstion :) ...

 >

>>>
>>>
>>> >
>>>
>>
>>
>> >
>>
>
>
> >
>



  
--~--~-~--~~~---~--~~
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: Anyone built a forum system yet?

2009-01-21 Thread brian

On Wed, Jan 21, 2009 at 11:41 PM, Jon Bennett  wrote:
>
> This shouldn't incur a massive DB hit, as even if you have 100,000
> threads, you won't display 100,000 on one page!

Yes. That's precisely the point that I think I should have pointed out
many comments ago. I don't know if it's that misconception that is
objectionable, or the notion that storing hundreds of thousands of
data points at all is somehow an abuse of a good DB.

--~--~-~--~~~---~--~~
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: Dynamic Model Call

2009-01-21 Thread brian

I don't think I understand what your question is, then. Yes, you can
use a variable as the model name, if used the way I showed you. But,
where did this error come from? If it was from the find() line, how is
it that your array has data in it?

On Wed, Jan 21, 2009 at 11:22 PM, Yusuf Widiyatmono  wrote:
> sorry it just a mark for the code line.
>
> Fatal error: Cannot access empty property in
> {some_directories_path}\app\controllers\areas_controller.php on line **
>
> i mean that i got that message from this line
>
> $model_data = $this->AreaInfo->$model_name->find('list');**
>
>
>
>
>
> 
> From: brian 
> To: cake-php@googlegroups.com
> Sent: Thursday, January 22, 2009 1:06:39 PM
> Subject: Re: Dynamic Model Call
>
>
> What is on line** (from the error msg)?
>
> On Wed, Jan 21, 2009 at 10:37 PM, Yusuf Widiyatmono 
> wrote:
>> the model is loaded...
>> see the print_r result, the model can retrieve some data,
>> but in the end the error still appear and make the further logic die
>>
>>
>>
>> 
>> From: brian 
>> To: cake-php@googlegroups.com
>> Sent: Thursday, January 22, 2009 12:30:22 PM
>> Subject: Re: Dynamic Model Call
>>
>>
>> Are these models loaded?
>>
>> On Wed, Jan 21, 2009 at 6:10 PM, Yusuf Widiyatmono 
>> wrote:
>>> i did and it still shows me same errors...
>>>
>>>
>>> 
>>> From: brian 
>>> To: cake-php@googlegroups.com
>>> Sent: Thursday, January 22, 2009 2:49:31 AM
>>> Subject: Re: Dynamic Model Call
>>>
>>>
>>> Try $this->AreaInfo->{$model_name}->find(...)
>>>
>>> On Wed, Jan 21, 2009 at 12:33 AM, wmonou  wrote:

 Helo there i am trying to call model from a variable

 let say that i have a code is like this:

// $model_name is a string
// bind necessary model
if(!empty($model_name)){
$this->AreaInfo->bindModel(
array(
'belongsTo'=>array(
$model_name => array(
'className' =>
 $model_name,
'foreignKey' =>
 'reference_id'
)
)
)
);
}

$model_data = $this->AreaInfo->$model_name->find('list');//
 **
 this is my question
print_r($model_data);

 the $model_data variable now is not empty, but i got something like
 this :

 Array
 (
[1] => 1
[2] => 2
[3] => 3
[4] => 4
[5] => 5
[6] => 6
[7] => 7
[8] => 8
[9] => 9
[10] => 10
[11] => 11
[12] => 12
[13] => 13
[14] => 14
[15] => 15
[16] => 16
[17] => 17
[18] => 18
[19] => 19
[20] => 20
 )

 Fatal error: Cannot access empty property in {some_directories_path}
 \app\controllers\areas_controller.php on line **

 is it possible to do such a thing like above? if yes or no please let
 me know with your sugesstion :) ...

 >

>>>
>>>
>>> >
>>>
>>
>>
>> >
>>
>
>
> >
>

--~--~-~--~~~---~--~~
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: Anyone built a forum system yet?

2009-01-21 Thread Jon Bennett

hi,

been watching this thread and thought I'd put my 2p in.

> I think you are trying to hard to formulate and verify data. (btw when i
> said hash previously I actually meant to say serialized data ... late hours)
> - plus, I now think that there is no need to use a cookie (other than
> typical session id, login status) - the user should know if they read a
> thread already so storing that data in the db makes more sense if they use
> multiple computers to access that forum (students, teachers, etc)

Personally, I would go with DB, with the following tables

Threads
Comments
Users

you then have 2 habtms

ThreadView habtm User
CommentView habtm User

Then, you then have a call to paginate the threads data. Then you need
to search your join model for all records matching the
Set::extract('{n}.Thread.id) and the active user_id. of your paginated
data.

With this array of read posts for the current set of threads, you can
pass to the view and check using a single if (in_array()) when looping
over your threads.

This shouldn't incur a massive DB hit, as even if you have 100,000
threads, you won't display 100,000 on one page!

You'd need to extend the functionality for Threads to Comments.

To implement this for non-signed in users, you could use cake's UUID
function to and create them a user record, just not an authenticated
one, a guest account. Store the uuid in a cookie and you'll always be
able to grab what they've read or not.

just an idea at least.

-- 

jon bennett
w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett

--~--~-~--~~~---~--~~
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: Dynamic Model Call

2009-01-21 Thread Yusuf Widiyatmono
sorry it just a mark for the code line. 

Fatal error: Cannot access empty property in 
{some_directories_path}\app\controllers\areas_controller.php on line **

i mean that i got that message from this line

$model_data = $this->AreaInfo->$model_name->find('list');**






From: brian 
To: cake-php@googlegroups.com
Sent: Thursday, January 22, 2009 1:06:39 PM
Subject: Re: Dynamic Model Call


What is on line** (from the error msg)?

On Wed, Jan 21, 2009 at 10:37 PM, Yusuf Widiyatmono  wrote:
> the model is loaded...
> see the print_r result, the model can retrieve some data,
> but in the end the error still appear and make the further logic die
>
>
>
> 
> From: brian 
> To: cake-php@googlegroups.com
> Sent: Thursday, January 22, 2009 12:30:22 PM
> Subject: Re: Dynamic Model Call
>
>
> Are these models loaded?
>
> On Wed, Jan 21, 2009 at 6:10 PM, Yusuf Widiyatmono  wrote:
>> i did and it still shows me same errors...
>>
>>
>> 
>> From: brian 
>> To: cake-php@googlegroups.com
>> Sent: Thursday, January 22, 2009 2:49:31 AM
>> Subject: Re: Dynamic Model Call
>>
>>
>> Try $this->AreaInfo->{$model_name}->find(...)
>>
>> On Wed, Jan 21, 2009 at 12:33 AM, wmonou  wrote:
>>>
>>> Helo there i am trying to call model from a variable
>>>
>>> let say that i have a code is like this:
>>>
>>>// $model_name is a string
>>>// bind necessary model
>>>if(!empty($model_name)){
>>>$this->AreaInfo->bindModel(
>>>array(
>>>'belongsTo'=>array(
>>>$model_name => array(
>>>'className' =>
>>> $model_name,
>>>'foreignKey' =>
>>> 'reference_id'
>>>)
>>>)
>>>)
>>>);
>>>}
>>>
>>>$model_data = $this->AreaInfo->$model_name->find('list');// **
>>> this is my question
>>>print_r($model_data);
>>>
>>> the $model_data variable now is not empty, but i got something like
>>> this :
>>>
>>> Array
>>> (
>>>[1] => 1
>>>[2] => 2
>>>[3] => 3
>>>[4] => 4
>>>[5] => 5
>>>[6] => 6
>>>[7] => 7
>>>[8] => 8
>>>[9] => 9
>>>[10] => 10
>>>[11] => 11
>>>[12] => 12
>>>[13] => 13
>>>[14] => 14
>>>[15] => 15
>>>[16] => 16
>>>[17] => 17
>>>[18] => 18
>>>[19] => 19
>>>[20] => 20
>>> )
>>>
>>> Fatal error: Cannot access empty property in {some_directories_path}
>>> \app\controllers\areas_controller.php on line **
>>>
>>> is it possible to do such a thing like above? if yes or no please let
>>> me know with your sugesstion :) ...
>>>
>>> >
>>>
>>
>>
>> >
>>
>
>
> >
>



  
--~--~-~--~~~---~--~~
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: Dynamic Model Call

2009-01-21 Thread brian

What is on line** (from the error msg)?

On Wed, Jan 21, 2009 at 10:37 PM, Yusuf Widiyatmono  wrote:
> the model is loaded...
> see the print_r result, the model can retrieve some data,
> but in the end the error still appear and make the further logic die
>
>
>
> 
> From: brian 
> To: cake-php@googlegroups.com
> Sent: Thursday, January 22, 2009 12:30:22 PM
> Subject: Re: Dynamic Model Call
>
>
> Are these models loaded?
>
> On Wed, Jan 21, 2009 at 6:10 PM, Yusuf Widiyatmono  wrote:
>> i did and it still shows me same errors...
>>
>>
>> 
>> From: brian 
>> To: cake-php@googlegroups.com
>> Sent: Thursday, January 22, 2009 2:49:31 AM
>> Subject: Re: Dynamic Model Call
>>
>>
>> Try $this->AreaInfo->{$model_name}->find(...)
>>
>> On Wed, Jan 21, 2009 at 12:33 AM, wmonou  wrote:
>>>
>>> Helo there i am trying to call model from a variable
>>>
>>> let say that i have a code is like this:
>>>
>>>// $model_name is a string
>>>// bind necessary model
>>>if(!empty($model_name)){
>>>$this->AreaInfo->bindModel(
>>>array(
>>>'belongsTo'=>array(
>>>$model_name => array(
>>>'className' =>
>>> $model_name,
>>>'foreignKey' =>
>>> 'reference_id'
>>>)
>>>)
>>>)
>>>);
>>>}
>>>
>>>$model_data = $this->AreaInfo->$model_name->find('list');// **
>>> this is my question
>>>print_r($model_data);
>>>
>>> the $model_data variable now is not empty, but i got something like
>>> this :
>>>
>>> Array
>>> (
>>>[1] => 1
>>>[2] => 2
>>>[3] => 3
>>>[4] => 4
>>>[5] => 5
>>>[6] => 6
>>>[7] => 7
>>>[8] => 8
>>>[9] => 9
>>>[10] => 10
>>>[11] => 11
>>>[12] => 12
>>>[13] => 13
>>>[14] => 14
>>>[15] => 15
>>>[16] => 16
>>>[17] => 17
>>>[18] => 18
>>>[19] => 19
>>>[20] => 20
>>> )
>>>
>>> Fatal error: Cannot access empty property in {some_directories_path}
>>> \app\controllers\areas_controller.php on line **
>>>
>>> is it possible to do such a thing like above? if yes or no please let
>>> me know with your sugesstion :) ...
>>>
>>> >
>>>
>>
>>
>> >
>>
>
>
> >
>

--~--~-~--~~~---~--~~
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: Anyone subscribe to PHP Architect?

2009-01-21 Thread Dr. Tarique Sani

I have been a subscriber since the first issue eons ago - all I can
say is it still is worth looking through - the current slew of ZF
articles seem to be incidental

Cheers
Tarique


On Wed, Jan 21, 2009 at 9:45 PM, aranworld  wrote:
>
> PHP Architect seems somewhat centered on the Zend Framework, so I'm
> wondering if it is a worthwhile magazine for someone whose main focus
> is CakePHP.



-- 
=
Cheesecake-Photoblog: http://cheesecake-photoblog.org
PHP for E-Biz: http://sanisoft.com
=

--~--~-~--~~~---~--~~
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: Dynamic Model Call

2009-01-21 Thread Yusuf Widiyatmono
the model is loaded...
see the print_r result, the model can retrieve some data, 
but in the end the error still appear and make the further logic die


 





From: brian 
To: cake-php@googlegroups.com
Sent: Thursday, January 22, 2009 12:30:22 PM
Subject: Re: Dynamic Model Call


Are these models loaded?

On Wed, Jan 21, 2009 at 6:10 PM, Yusuf Widiyatmono  wrote:
> i did and it still shows me same errors...
>
>
> 
> From: brian 
> To: cake-php@googlegroups.com
> Sent: Thursday, January 22, 2009 2:49:31 AM
> Subject: Re: Dynamic Model Call
>
>
> Try $this->AreaInfo->{$model_name}->find(...)
>
> On Wed, Jan 21, 2009 at 12:33 AM, wmonou  wrote:
>>
>> Helo there i am trying to call model from a variable
>>
>> let say that i have a code is like this:
>>
>>// $model_name is a string
>>// bind necessary model
>>if(!empty($model_name)){
>>$this->AreaInfo->bindModel(
>>array(
>>'belongsTo'=>array(
>>$model_name => array(
>>'className' => $model_name,
>>'foreignKey' =>
>> 'reference_id'
>>)
>>)
>>)
>>);
>>}
>>
>>$model_data = $this->AreaInfo->$model_name->find('list');// **
>> this is my question
>>print_r($model_data);
>>
>> the $model_data variable now is not empty, but i got something like
>> this :
>>
>> Array
>> (
>>[1] => 1
>>[2] => 2
>>[3] => 3
>>[4] => 4
>>[5] => 5
>>[6] => 6
>>[7] => 7
>>[8] => 8
>>[9] => 9
>>[10] => 10
>>[11] => 11
>>[12] => 12
>>[13] => 13
>>[14] => 14
>>[15] => 15
>>[16] => 16
>>[17] => 17
>>[18] => 18
>>[19] => 19
>>[20] => 20
>> )
>>
>> Fatal error: Cannot access empty property in {some_directories_path}
>> \app\controllers\areas_controller.php on line **
>>
>> is it possible to do such a thing like above? if yes or no please let
>> me know with your sugesstion :) ...
>>
>> >
>>
>
>
> >
>



  
--~--~-~--~~~---~--~~
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: Dynamic Model Call

2009-01-21 Thread brian

Are these models loaded?

On Wed, Jan 21, 2009 at 6:10 PM, Yusuf Widiyatmono  wrote:
> i did and it still shows me same errors...
>
>
> 
> From: brian 
> To: cake-php@googlegroups.com
> Sent: Thursday, January 22, 2009 2:49:31 AM
> Subject: Re: Dynamic Model Call
>
>
> Try $this->AreaInfo->{$model_name}->find(...)
>
> On Wed, Jan 21, 2009 at 12:33 AM, wmonou  wrote:
>>
>> Helo there i am trying to call model from a variable
>>
>> let say that i have a code is like this:
>>
>>// $model_name is a string
>>// bind necessary model
>>if(!empty($model_name)){
>>$this->AreaInfo->bindModel(
>>array(
>>'belongsTo'=>array(
>>$model_name => array(
>>'className' => $model_name,
>>'foreignKey' =>
>> 'reference_id'
>>)
>>)
>>)
>>);
>>}
>>
>>$model_data = $this->AreaInfo->$model_name->find('list');// **
>> this is my question
>>print_r($model_data);
>>
>> the $model_data variable now is not empty, but i got something like
>> this :
>>
>> Array
>> (
>>[1] => 1
>>[2] => 2
>>[3] => 3
>>[4] => 4
>>[5] => 5
>>[6] => 6
>>[7] => 7
>>[8] => 8
>>[9] => 9
>>[10] => 10
>>[11] => 11
>>[12] => 12
>>[13] => 13
>>[14] => 14
>>[15] => 15
>>[16] => 16
>>[17] => 17
>>[18] => 18
>>[19] => 19
>>[20] => 20
>> )
>>
>> Fatal error: Cannot access empty property in {some_directories_path}
>> \app\controllers\areas_controller.php on line **
>>
>> is it possible to do such a thing like above? if yes or no please let
>> me know with your sugesstion :) ...
>>
>> >
>>
>
>
> >
>

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



Localizate Month Names

2009-01-21 Thread Diego Caro

Hi for all.

I read [1], but that method doesn't works for me. I want to translate
the short name a month (for example: "Jan", to "Ene" in spanish )
using TimeHelper (timeAgoInWords function). How to make it?

Thanks, and good luck ;-).

[1] 
http://groups.google.com/group/cake-php/browse_thread/thread/6d130fdab7c0d45f/3e224389f5b4ebbf?lnk=gst&q=l10n+date

--~--~-~--~~~---~--~~
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 sum up the duration time based on the application used?

2009-01-21 Thread Mr Chaz

$apps = $this->Application->find('all', array('conditions' => array
('Application.Username' => $username, 'Application.Duration !=' =>
null)));

debug ($qwe = Set::combine($apps,
'{n}.Application.id','{n}.Application.Duration',
'{n}.Application.ProcessDescription'));


Array
(
[Google Talk] => Array
(
[2] => 00:00:09
[16] => 00:00:37
[23] => 00:00:14
[25] => 00:01:11
[181] => 00:00:13
[182] => 00:00:11
[183] => 00:00:01
[184] => 00:00:09
[185] => 00:00:02
[186] => 00:00:14
[187] => 00:00:09
[188] => 00:00:09
[189] => 00:01:12
[190] => 00:00:04
[191] => 00:00:15
[500] => 00:00:20
[501] => 00:00:03
[502] => 00:10:23
[504] => 00:00:18
[506] => 00:00:01
[508] => 00:06:00
[630] => 00:00:05
[633] => 00:00:01
)

[AVG Update downloader] => Array
(
[3] => 00:00:27
[123] => 00:00:01
)

--~--~-~--~~~---~--~~
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: MVC Desing tips

2009-01-21 Thread Webweave

Yes, there is a learning curve for Cake, it took me a couple of weeks
to even figure out that bake was the right way to get started.

On Jan 21, 2:03 pm, Andrea Cardinale  wrote:
> On Wed, Jan 21, 2009 at 9:39 PM, Webweave  wrote:
> > I would suggest going through the Cookbook and doing a bake to get
> > started.
>
> > My typical dev cycle for Cake is:
>
> >  1. Build some tables
> >  2. Bake the app
> >  3. Bake the models, views and controllers
> >  4. Modify as needed.
>
> > See:http://book.cakephp.org/view/113/Code-Generation-with-Bake
>
> I've already read a big part of the Cookbook, and doing to the huge
> amount of info forget an half of it, but now I know where the things I
> need are and I'm using it as a reference. I think is good to get
> started and to deal with basic task, but for example I can't find a
> solution to my problem, just some suggestion and none of them so
> sound.
> Anyway thanks for the reply;)
>
> Andrea
--~--~-~--~~~---~--~~
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: getLastInsertId or something similar

2009-01-21 Thread Webweave

You would only need to use the getLastInsertId() if you had inserted
something and then immediately needed to add related data.

If your forms walk you through some process which goes to another
controller, you'd either need to pass the data along, or fetch it
again.

Like I said before, I have a similar thing where I create a new user
and register them for a slot. So, what I do is have an action in my
User controller that first creates the User, then does the
getLastInsertId, then adds the related row.

The getLastInsertId call comes after the save for each data bit and is
used in the foreign key field for the related data before that is
saved.

So, lets say you want to add a new user and a few events. You would do
the following:

1. Insert the user data using a $this->User->save($this->data)
2. Save the user ID into a field by calling $this->User-
>getLastInsertId()
   $user_id = $this->User->getLastInsertId();
3. Loop through the event data and update the foreign key field with
the saved user ID
   $this->data['Event']['user_id'] = $user_id;
4. Save the event data ($this->User->Event->save($this->data
['Event'];)
5. drop through to your next view as normal depending on success or
failure of the above.



On Jan 21, 4:13 pm, mike  wrote:
> does this mean I can't use getLastInsertId() if I inserted the event
> in another controller? (this was one of my original questions)
>
> In the events controller, I save the event, then redirect to the user
> view.  In the user controller is where I'm trying to get the event_id
> I just inserted.
>
> On Jan 21, 4:49 pm, Webweave  wrote:
>
> > It will only return a value after you do an insert (a save of the new
> > Event).
>
> > Post the action you are having trouble with, and perhaps we can spot
> > the issue.
>
> > On Jan 19, 3:41 pm, mike  wrote:
>
> > > eeerrr, this is not working.
>
> > > I have this in the User model:
> > > var $hasMany = array ('Event');
>
> > > this in the event model:
> > >     var $belongsTo = array (
> > >                 'User' => array(
> > >             'className'    => 'User',
> > >             'foreignKey'    => 'creator_id',
> > >                 )
> > >         );
>
> > > $this->User->Event->getLastInsertId() in the users controller returns
> > > nothing!
>
> > > what am I missing??
>
> > > On Jan 19, 3:01 am, "Jon Bennett"  wrote:
>
> > > > > where do I grab the lastInsertId()?  in the event_controller?  and
> > > > >  then how do I pass it to the user view?
>
> > > > provided you've correctly set up your model associations, which I think 
> > > > are:
>
> > > > User hasMany Event
> > > > Event belongsTo User
>
> > > > From your Users controller you can do:
>
> > > > $event_id = $this->User->Event->getLastInsertId();
>
> > > > hth
>
> > > > jon
>
> > > > --
>
> > > > jon bennett
> > > > w:http://www.jben.net/
> > > > iChat (AIM): jbendotnet Skype: jon-bennett- Hide quoted text -
>
> > - Show quoted text -
>
>
--~--~-~--~~~---~--~~
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: getLastInsertId or something similar

2009-01-21 Thread Yusuf Widiyatmono
you can only get the value of getLastInsertId() method after saving something...

you have to do this before
$this->User->Event->save($this_data);
$last_event_id = $this->User->Event->getLastInsertId();

and this getLastInsertId() method is only working for save() method to insert 
new record to events table in database.
for using save() method to update a record, the getLastInsertId, will not give 
you anything too


---
is this the answer that you mean? sorry if i am mistaken what your question.



 Best Regards



Yusuf Widiyatmono

Software Engineer
Phone +62 (361) 755 025
Facsimile +62 (361) 755 024
Mobile +62 813 2126 4488
www.mitrais.com






From: mike 
To: CakePHP 
Sent: Thursday, January 22, 2009 9:13:48 AM
Subject: Re: getLastInsertId or something similar


does this mean I can't use getLastInsertId() if I inserted the event
in another controller? (this was one of my original questions)

In the events controller, I save the event, then redirect to the user
view.  In the user controller is where I'm trying to get the event_id
I just inserted.

On Jan 21, 4:49 pm, Webweave  wrote:
> It will only return a value after you do an insert (a save of the new
> Event).
>
> Post the action you are having trouble with, and perhaps we can spot
> the issue.
>
> On Jan 19, 3:41 pm, mike  wrote:
>
>
>
> > eeerrr, this is not working.
>
> > I have this in the User model:
> > var $hasMany = array ('Event');
>
> > this in the event model:
> > var $belongsTo = array (
> > 'User' => array(
> > 'className'=> 'User',
> > 'foreignKey'=> 'creator_id',
> > )
> > );
>
> > $this->User->Event->getLastInsertId() in the users controller returns
> > nothing!
>
> > what am I missing??
>
> > On Jan 19, 3:01 am, "Jon Bennett"  wrote:
>
> > > > where do I grab the lastInsertId()?  in the event_controller?  and
> > > >  then how do I pass it to the user view?
>
> > > provided you've correctly set up your model associations, which I think 
> > > are:
>
> > > User hasMany Event
> > > Event belongsTo User
>
> > > From your Users controller you can do:
>
> > > $event_id = $this->User->Event->getLastInsertId();
>
> > > hth
>
> > > jon
>
> > > --
>
> > > jon bennett
> > > w:http://www.jben.net/
> > > iChat (AIM): jbendotnet Skype: jon-bennett- Hide quoted text -
>
> - Show quoted text -


  
--~--~-~--~~~---~--~~
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: Yet Another HABTM Save Question

2009-01-21 Thread Rob Wilkerson


On Jan 20, 7:47 pm, Rob Wilkerson  wrote:
> On Tue, Jan 20, 2009 at 7:40 PM, brian  wrote:
>
> > Yeah, that's the bit that has me confused, also. Even before seeing
> > your comment, I was wondering why it would set the value, then create
> > another UUID. I don't get it.
>
> Color me stuck, too. I tried the IRC channel, but no one there was
> able to help. I don't know whether it's truly a bug or something I
> just don't understand correctly, but I'll try again tomorrow and see
> if someone is available.

For whatever it's worth, the problem seems to be fixed in the latest
stable release (1.2.1.8004) I'm not sure what changed (I didn't see
anything obvious in a quick glance at Model::__saveMulti()), but
everything seems to be working as expected now. The only change I've
made is the upgrade itself.
--~--~-~--~~~---~--~~
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: getLastInsertId or something similar

2009-01-21 Thread mike

does this mean I can't use getLastInsertId() if I inserted the event
in another controller? (this was one of my original questions)

In the events controller, I save the event, then redirect to the user
view.  In the user controller is where I'm trying to get the event_id
I just inserted.

On Jan 21, 4:49 pm, Webweave  wrote:
> It will only return a value after you do an insert (a save of the new
> Event).
>
> Post the action you are having trouble with, and perhaps we can spot
> the issue.
>
> On Jan 19, 3:41 pm, mike  wrote:
>
>
>
> > eeerrr, this is not working.
>
> > I have this in the User model:
> > var $hasMany = array ('Event');
>
> > this in the event model:
> >     var $belongsTo = array (
> >                 'User' => array(
> >             'className'    => 'User',
> >             'foreignKey'    => 'creator_id',
> >                 )
> >         );
>
> > $this->User->Event->getLastInsertId() in the users controller returns
> > nothing!
>
> > what am I missing??
>
> > On Jan 19, 3:01 am, "Jon Bennett"  wrote:
>
> > > > where do I grab the lastInsertId()?  in the event_controller?  and
> > > >  then how do I pass it to the user view?
>
> > > provided you've correctly set up your model associations, which I think 
> > > are:
>
> > > User hasMany Event
> > > Event belongsTo User
>
> > > From your Users controller you can do:
>
> > > $event_id = $this->User->Event->getLastInsertId();
>
> > > hth
>
> > > jon
>
> > > --
>
> > > jon bennett
> > > w:http://www.jben.net/
> > > iChat (AIM): jbendotnet Skype: jon-bennett- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
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: Saving with AJAX and jQuery

2009-01-21 Thread Andras Kende

Change $this->set($data, $fieldName); to: $this->set('data', $fieldName);

Monitor ajax it with like firebug 

Andras

-Original Message-
From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf
Of WidePixels
Sent: Tuesday, January 20, 2009 10:34 PM
To: CakePHP
Subject: Saving with AJAX and jQuery


I am trying to save the fields in a form using a function rather than
1 set for each field. I was trying to get the $data and $fieldname
idea going where based on the field and data it would update the db
correctly.

This is the code inside the controller:

function update($data, $fieldName) {
if ($this->data) {
App::import('Core', 'sanitize');
$fieldName = Sanitize::clean($this->data
['User'][$fieldName]);

$this->User->id = $this->data['User']['id'];
$this->User->saveField($data, $fieldName);
$this->set($data, $fieldName);
}
}

the javascript looks like this

$(function() {

$('.click').editable('/users/update', {
 id: 'data[User][id]',
 name  : '$fieldName',
 indicator : "",
 tooltip   : "Click to edit...",
 style  : "inherit"
});
});

The update.ctp view is:







Can any one tell me what i am doing wrong or point me in the right
direction?

Thanks.



--~--~-~--~~~---~--~~
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: complex problem

2009-01-21 Thread websta*

Not quite sure on the finer points of how the reordering of the routes
causes your urls to correct themselves (in this instance at least)

But am curios: what about if you create your link url like:

link('+ add new
post',array('controller'=>'Posts','action'=>'add', 'prefix'=>'admin'))) ?>


-Original Message-
From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf
Of medo
Sent: Thursday, January 22, 2009 10:09 AM
To: CakePHP
Subject: complex problem


hi group

today i have really complex problem when i try to implement a site
with two back end interface one for the superadmin interface which
offered  to enter the global site config. and the second one is the
admin interface which offered to admin the site content and i didn't
use core.php using Configure::write('Routing.admin', 'admin') i use
the routes.php with these two lines

Router::connect('/superadmin/:controller/:action/*', array('prefix' =>
'superadmin'));
Router::connect('/admin/:controller/:action/*', array('prefix' =>
'admin'));

and after that i continue to implement the first controller which is
the posts controller and the problem appear when i try to add a link
in the admin_index.ctp view of the posts controller to the action add
of the same controller. the problem is when i use the verbose link the
route system give wrong link like this

[ admin_index.ctp of Posts controller ]
..
link('+ add new post',array
('controller'=>'Posts','action'=>'admin_add'))) ?>
..

the result link will be

/superadmin/posts/admin_add  [ wrong link ]

but when i rearrange the route line to become like this

Router::connect('/admin/:controller/:action/*', array('prefix' =>
'admin'));
Router::connect('/superadmin/:controller/:action/*', array('prefix' =>
'superadmin'));

i get the right link like below

/admin/posts/add

is there any solution to this problem which will i face it again when
i'll work with the superadmin interface


Internal Virus Database is out of date.
Checked by AVG - http://www.avg.com 
Version: 8.0.176 / Virus Database: 270.10.8/1899 - Release Date: 1/17/2009
5:50 PM


--~--~-~--~~~---~--~~
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: Custom queries test

2009-01-21 Thread websta*

If you get your database connection details from the ConnectionManager you
will at least be able to deduce your table prefix and integrate this into
your querries.

-Original Message-
From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf
Of Fabio Kreusch
Sent: Thursday, January 22, 2009 10:48 AM
To: CakePHP
Subject: Custom queries test


Hello all!

I'm thinking about on how to test custom queries in a model.

Suppose I have something like this in a model:

function doSomethingWithCustomQuery() {
  return $this->query('SELECT * FROM table');
}

How can I test this using the fixtures and all?
My main problem is how to detect the test environment
so I can, for exemple, attach 'test_suite' to the table name,
so the query will run on the test table.

How can I do this?


Internal Virus Database is out of date.
Checked by AVG - http://www.avg.com 
Version: 8.0.176 / Virus Database: 270.10.8/1899 - Release Date: 1/17/2009
5:50 PM


--~--~-~--~~~---~--~~
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: MVC Desing tips

2009-01-21 Thread Andrea Cardinale

On Wed, Jan 21, 2009 at 9:39 PM, Webweave  wrote:
> I would suggest going through the Cookbook and doing a bake to get
> started.
>
> My typical dev cycle for Cake is:
>
>  1. Build some tables
>  2. Bake the app
>  3. Bake the models, views and controllers
>  4. Modify as needed.
>
> See: http://book.cakephp.org/view/113/Code-Generation-with-Bake
>

I've already read a big part of the Cookbook, and doing to the huge
amount of info forget an half of it, but now I know where the things I
need are and I'm using it as a reference. I think is good to get
started and to deal with basic task, but for example I can't find a
solution to my problem, just some suggestion and none of them so
sound.
Anyway thanks for the reply;)

Andrea

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



Custom queries test

2009-01-21 Thread Fabio Kreusch

Hello all!

I'm thinking about on how to test custom queries in a model.

Suppose I have something like this in a model:

function doSomethingWithCustomQuery() {
  return $this->query('SELECT * FROM table');
}

How can I test this using the fixtures and all?
My main problem is how to detect the test environment
so I can, for exemple, attach 'test_suite' to the table name,
so the query will run on the test table.

How can I do this?

--~--~-~--~~~---~--~~
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: Anyone built a forum system yet?

2009-01-21 Thread Brian Williams
brian,

I think you are trying to hard to formulate and verify data. (btw when i
said hash previously I actually meant to say serialized data ... late hours)
- plus, I now think that there is no need to use a cookie (other than
typical session id, login status) - the user should know if they read a
thread already so storing that data in the db makes more sense if they use
multiple computers to access that forum (students, teachers, etc)

So let's say for the sake of example your serialized data is essentially an
array
$read_threads =
array(array('thread_id'=>12),array('last_date_visited'),array('thread_id'=>16),array('last_date_visited'))

when the list of threads is displayed you check against the
last_visited_date for the specific thread ID

foreach($read_threads as $n=>$v){
   if($thread($v['thread_id'])->messages->last_post_date() >
$v['last_date_visited'])
 //print out the right icon, or set the appropriate status variable
for use in smarty, etc

the foreach (or a regular for) works perfectly fine because you would use
that anyways to print the list of threads

then when they view a page of the thread's messages you update the
array/object/session with the last post date of that thread, save to the db

anyways, thats what i was thinking.



On Wed, Jan 21, 2009 at 1:17 PM, brian  wrote:

>
> On Wed, Jan 21, 2009 at 12:43 AM, Brian Williams 
> wrote:
> > not to step on toes but i'm not sure why it's such a problem storing that
> > data in a db...
> >
> > if you want quick access to the data but not a zillion records make a
> hash,
> > and store that hash in the db and a cookie.
> >
> > when the user logs in, read the hash and store into their session and
> save
> > it in their cookie until they log out.
>
> That seems like a good idea, but how would you get the thread IDs from
> a hash? The only way I can see that working is if you hashed every
> combination of thread IDs (plus whatever user-specific info you
> previously hashed) and tested against what was stored in the cookie.
> Obviously, that wouldn't be very efficient. What did you have in mind?
>
> >
>

--~--~-~--~~~---~--~~
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: Dynamic Model Call

2009-01-21 Thread Yusuf Widiyatmono
i did and it still shows me same errors...

 





From: brian 
To: cake-php@googlegroups.com
Sent: Thursday, January 22, 2009 2:49:31 AM
Subject: Re: Dynamic Model Call


Try $this->AreaInfo->{$model_name}->find(...)

On Wed, Jan 21, 2009 at 12:33 AM, wmonou  wrote:
>
> Helo there i am trying to call model from a variable
>
> let say that i have a code is like this:
>
>// $model_name is a string
>// bind necessary model
>if(!empty($model_name)){
>$this->AreaInfo->bindModel(
>array(
>'belongsTo'=>array(
>$model_name => array(
>'className' => $model_name,
>'foreignKey' => 'reference_id'
>)
>)
>)
>);
>}
>
>$model_data = $this->AreaInfo->$model_name->find('list');// **
> this is my question
>print_r($model_data);
>
> the $model_data variable now is not empty, but i got something like
> this :
>
> Array
> (
>[1] => 1
>[2] => 2
>[3] => 3
>[4] => 4
>[5] => 5
>[6] => 6
>[7] => 7
>[8] => 8
>[9] => 9
>[10] => 10
>[11] => 11
>[12] => 12
>[13] => 13
>[14] => 14
>[15] => 15
>[16] => 16
>[17] => 17
>[18] => 18
>[19] => 19
>[20] => 20
> )
>
> Fatal error: Cannot access empty property in {some_directories_path}
> \app\controllers\areas_controller.php on line **
>
> is it possible to do such a thing like above? if yes or no please let
> me know with your sugesstion :) ...
>
> >
>



  
--~--~-~--~~~---~--~~
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: Relationships - HABTM

2009-01-21 Thread Steven Wright
Thank you.


 

-Original Message-
From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf
Of Webweave
Sent: Wednesday, January 21, 2009 4:33 PM
To: CakePHP
Subject: Re: Relationships - HABTM

http://book.cakephp.org/view/439/recursive

On Jan 19, 7:57 am, "rhythmicde...@gmail.com"
 wrote:
> I have been making some pretty good headway on defining the 
> relationships for my models. However I am not getting some data that I 
> expect to get. This may be due to my relationship definitions or a 
> misunderstanding of what CakePHP will do for me. I am hoping one you 
> can point me in the right direction.
>
> So am I missing something here? Wrong relationship definition? Wrong 
> expectation?
>
> Thanks in advance.
> Steve
>
> I have the following models and relationship definitions:
>
> Recipe
> var $hasAndBelongsToMany = array(
>         'Ingredient' =>
>             array(
>                 'className'              => 'Ingredient',
>                 'joinTable'              => 'ingredient_lists',
>                 'foreignKey'             => 'recipe_id',
>                 'associationForeignKey'  => 'ingredient_id',
>                 'unique'                 => true
>                 ),
>            'MeasurementType' =>
>             array(
>                 'className'              => 'MeasurementType',
>                 'joinTable'              => 'ingredient_lists',
>                 'foreignKey'             => 'recipe_id',
>                 'associationForeignKey'  => 'measurement_type_id',
>                 'unique'                 => true
>                 )
>     );
>
> IngredientList
> var $belongsTo = array('Recipe', 'MeasurementType');
>
> Ingredient
> var $belongsTo = 'IngredientType';
>
> I set the recipe for the view var in the controller like so:
> $this->set('recipe', $this->Recipe->read());
>
> I expect that when I view the recipe array in the view I should see a 
> multi-array. Each Ingredient array should have a sub array that 
> contains the ingredient, ingredient_type and measurement_type. But 
> this is not the case.
>
> When I do a debug of the $this->viewVars in the view view I get the 
> following output. As you can see the MeasurementType array is not 
> under the Ingredient array.
>
> app\views\recipes\view.ctp (line 37)
>
> Array
> (
>     [Recipe] => Array
>         (
>             [id] => 02
>             [recipe] => Cranberry Orange Bake
>             [description] => A classic casserole with a festive flair.
>             [instructions] => Preheat the oven to 400 degrees.
> Prepare stuffing mixture as directed on box substituting orange juice 
> and water for broth. Stir the cranberries and pecans in with the 
> stuffing mix.
>
> Combine the soup, Quorn and vegetables. Spoon into an 13x9 baking dish 
> and top with the stuffing mixture.
>
> Bake for 30min or until cooked through.
>             [servings] => 6
>             [recipe_type_id] => 06
>             [created] => 2009-01-16 10:35:19
>             [modified] => 2009-01-16 10:43:15
>         )
>
>     [Ingredient] => Array
>         (
>             [0] => Array
>                 (
>                     [id] => 31
>                     [ingredient] => stuffing mix
>                     [ingredient_type_id] => 19
>                     [description] =>
>                     [created] => 2009-01-09 20:10:44
>                     [modified] => 2009-01-09 20:13:14
>                     [IngredientList] => Array
>                         (
>                             [id] => 05
>                             [recipe_id] => 02
>                             [ingredient] => stuffing mix
>                             [fractional_amount] =>
>                             [whole_amount] => 6
>                             [measurement_type_id] => 01
>                             [description] =>
>                             [created] => 2009-01-16 10:35:19
>                             [modified] => 2009-01-16 10:43:15
>                             [ingredient_id] => 31
>                         )
>
>                 )
>
>             [1] => Array
>                 (
>                     [id] => 32
>                     [ingredient] => orange juice
>                     [ingredient_type_id] => 21
>                     [description] =>
>                     [created] => 2009-01-09 20:13:31
>                     [modified] => 2009-01-09 20:13:31
>                     [IngredientList] => Array
>                         (
>                             [id] => 06
>                             [recipe_id] => 02
>                             [ingredient] => orange juice
>                             [fractional_amount] =>
>                             [whole_amount] => 1
>                             [measurement_type_id] => 02
>                             [description] =>
>                             [cre

Several values in one form element

2009-01-21 Thread Jakob Malm

Hi,

I have an order form, with a number of rows, one for each product and
size. The user can type in a simple input field the number of products
of that size he/she would like to order.

The following models and relationships exist:
Order, hasMany { OrderRow }
OrderRow, hasOne { Product, Size } (+ a field called amount)
Product, hasAndBelongsToMany { Size }
Size, hasAndBelongsToMany { Product }

How do I make form elements that include the id's of Product and Size
of the specific row, and the amount, all included in the data
correctly? In my mind, something like the following:

$form->input ( 'OrderRow.product_id.size_id.antal' );

and somehow populate the product_id and size_id fields with the
correct values.

I appreciate any help,
Jakob
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Restrict Controllers by Group

2009-01-21 Thread Pyrite

Is there a way I can restrict controllers by group?

Like $this->Auth->require('someGroup');

Otherwise, if the user is not a member of that group they don't get
access.

Also, where does the information in $this->Auth->user() get set? It
has the group_id but not the name of the group.
--~--~-~--~~~---~--~~
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: getLastInsertId or something similar

2009-01-21 Thread Webweave

It will only return a value after you do an insert (a save of the new
Event).

Post the action you are having trouble with, and perhaps we can spot
the issue.

On Jan 19, 3:41 pm, mike  wrote:
> eeerrr, this is not working.
>
> I have this in the User model:
> var $hasMany = array ('Event');
>
> this in the event model:
>     var $belongsTo = array (
>                 'User' => array(
>             'className'    => 'User',
>             'foreignKey'    => 'creator_id',
>                 )
>         );
>
> $this->User->Event->getLastInsertId() in the users controller returns
> nothing!
>
> what am I missing??
>
> On Jan 19, 3:01 am, "Jon Bennett"  wrote:
>
> > > where do I grab the lastInsertId()?  in the event_controller?  and
> > >  then how do I pass it to the user view?
>
> > provided you've correctly set up your model associations, which I think are:
>
> > User hasMany Event
> > Event belongsTo User
>
> > From your Users controller you can do:
>
> > $event_id = $this->User->Event->getLastInsertId();
>
> > hth
>
> > jon
>
> > --
>
> > jon bennett
> > w:http://www.jben.net/
> > iChat (AIM): jbendotnet Skype: jon-bennett
>
>
--~--~-~--~~~---~--~~
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: MVC Desing tips

2009-01-21 Thread Webweave

I would suggest going through the Cookbook and doing a bake to get
started.

My typical dev cycle for Cake is:

  1. Build some tables
  2. Bake the app
  3. Bake the models, views and controllers
  4. Modify as needed.

See: http://book.cakephp.org/view/113/Code-Generation-with-Bake



On Jan 19, 1:11 pm, Mirthis  wrote:
> Hi guys!
> I'm pretty new to Cake PHP and what I find really hard, being used to
> develop PHP without following any rule or schema, is to get used to
> the MVC design.model. In this moment I'm creating stuff without any
> particular purpose in mind, but just to get confident with the
> framework and to build something I''ll be able to reuse later
> What I have in mind is pretty simple. I want a site where different
> kind of contents can be published: news, pics, videos, etc. I think
> each of them can be displayed in a different section of the site and
> so easily implemented through a controller (NewsController,
> VideosController, etc.), its model and a set of views to access
> standard operations: browse, add, edit and delete contents.
> Now I want to add a feature shared among all this controllers to let
> user add comments to a conent. All comments will have the sane info
> (username, date, text, etc.) and should be displayed and managed in
> the same way regardless of the section where they're posted. It sounds
> simple but I have no idea on how to design it following MVC
> principles.
>
> Model
> I was thinking of having a unique table for all the comments and a set
> of associatives tables, one for each type of contents, to store
> association between a comment and a content item. Is not the best
> approach if we think about performance, so an alternative could be to
> have separate commments tables to speed up filtering. Anyway is not my
> first concern now.
>
> Controller
> I have two idea on how to implement the basic actions, but none of
> them looks right to me. The first is to have a comments controller
> class implementing the actions and then to create a set of subclasses,
> one for each type of contents, so I would have NewsCommentsController,
> VideosCommentsController, etc. In the subclasses I'd declare the right
> instance of the Model and call the superclass actions. The other idea
> is to have a component implementing the shared functionalities, but
> I've no idea if it's the right way to use a component and on how to do
> it.
>
> View
> I figure out I should have at least a view (or maybe an element?) to
> add a comment and one to show them, and that's all.
>
> A part from this what I can't understand well is how to put together
> all the pieces to obtain the final result. For instance having a main
> controller and its view, for example showing news, how can I add the
> action for posting/showing comments (that are in a different
> controller or component) and it's related view in the same page?
> U hope someone can give me some wise tips.And if someone is not clear,
> pleas ask me, I'm not a native english speaker and so I do lot of
> confusion some times.
> Thanks;)
>
> Andrea
--~--~-~--~~~---~--~~
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: Relationships - HABTM

2009-01-21 Thread Webweave
http://book.cakephp.org/view/439/recursive

On Jan 19, 7:57 am, "rhythmicde...@gmail.com"
 wrote:
> I have been making some pretty good headway on defining the
> relationships for my models. However I am not getting some data that I
> expect to get. This may be due to my relationship definitions or a
> misunderstanding of what CakePHP will do for me. I am hoping one you
> can point me in the right direction.
>
> So am I missing something here? Wrong relationship definition? Wrong
> expectation?
>
> Thanks in advance.
> Steve
>
> I have the following models and relationship definitions:
>
> Recipe
> var $hasAndBelongsToMany = array(
>         'Ingredient' =>
>             array(
>                 'className'              => 'Ingredient',
>                 'joinTable'              => 'ingredient_lists',
>                 'foreignKey'             => 'recipe_id',
>                 'associationForeignKey'  => 'ingredient_id',
>                 'unique'                 => true
>                 ),
>            'MeasurementType' =>
>             array(
>                 'className'              => 'MeasurementType',
>                 'joinTable'              => 'ingredient_lists',
>                 'foreignKey'             => 'recipe_id',
>                 'associationForeignKey'  => 'measurement_type_id',
>                 'unique'                 => true
>                 )
>     );
>
> IngredientList
> var $belongsTo = array('Recipe', 'MeasurementType');
>
> Ingredient
> var $belongsTo = 'IngredientType';
>
> I set the recipe for the view var in the controller like so:
> $this->set('recipe', $this->Recipe->read());
>
> I expect that when I view the recipe array in the view I should see a
> multi-array. Each Ingredient array should have a sub array that
> contains the ingredient, ingredient_type and measurement_type. But
> this is not the case.
>
> When I do a debug of the $this->viewVars in the view view I get the
> following output. As you can see the MeasurementType array is not
> under the Ingredient array.
>
> app\views\recipes\view.ctp (line 37)
>
> Array
> (
>     [Recipe] => Array
>         (
>             [id] => 02
>             [recipe] => Cranberry Orange Bake
>             [description] => A classic casserole with a festive flair.
>             [instructions] => Preheat the oven to 400 degrees.
> Prepare stuffing mixture as directed on box substituting orange juice
> and water for broth. Stir the cranberries and pecans in with the
> stuffing mix.
>
> Combine the soup, Quorn and vegetables. Spoon into an 13x9 baking dish
> and top with the stuffing mixture.
>
> Bake for 30min or until cooked through.
>             [servings] => 6
>             [recipe_type_id] => 06
>             [created] => 2009-01-16 10:35:19
>             [modified] => 2009-01-16 10:43:15
>         )
>
>     [Ingredient] => Array
>         (
>             [0] => Array
>                 (
>                     [id] => 31
>                     [ingredient] => stuffing mix
>                     [ingredient_type_id] => 19
>                     [description] =>
>                     [created] => 2009-01-09 20:10:44
>                     [modified] => 2009-01-09 20:13:14
>                     [IngredientList] => Array
>                         (
>                             [id] => 05
>                             [recipe_id] => 02
>                             [ingredient] => stuffing mix
>                             [fractional_amount] =>
>                             [whole_amount] => 6
>                             [measurement_type_id] => 01
>                             [description] =>
>                             [created] => 2009-01-16 10:35:19
>                             [modified] => 2009-01-16 10:43:15
>                             [ingredient_id] => 31
>                         )
>
>                 )
>
>             [1] => Array
>                 (
>                     [id] => 32
>                     [ingredient] => orange juice
>                     [ingredient_type_id] => 21
>                     [description] =>
>                     [created] => 2009-01-09 20:13:31
>                     [modified] => 2009-01-09 20:13:31
>                     [IngredientList] => Array
>                         (
>                             [id] => 06
>                             [recipe_id] => 02
>                             [ingredient] => orange juice
>                             [fractional_amount] =>
>                             [whole_amount] => 1
>                             [measurement_type_id] => 02
>                             [description] =>
>                             [created] => 2009-01-16 10:35:19
>                             [modified] => 2009-01-16 10:43:15
>                             [ingredient_id] => 32
>                         )
>
>                 )
>
>             [2] => Array
>  

Re: HABTM - fields in jointable

2009-01-21 Thread Webweave

Well, again, I'm not sure what you're asking, have you looked at the
Cookbook ? http://book.cakephp.org/view/439/recursive


On Jan 20, 4:52 am, Ernesto  wrote:
> i'm working on that bug :)
>
> can someone please explain me how cake loads related data? is there
> any doc i can read? i haven't find :(
>
> On 19 Gen, 17:03, Webweave  wrote:
>
> > What do you mean it doesn't work? Is it not firing, or are you getting
> > an error ?
>
> > On Jan 19, 7:05 am, Ernesto  wrote:
>
> > > uhm... i -partially- found the solution...
>
> > > if i load data from Customers_Controller the order_customer::afterFind
> > > doesn't work...
>
> > > On 19 Gen, 15:29, Ernesto  wrote:
>
> > > > ok i found the solution
>
> > > >  > > > class Recipe extends AppModel {
> > > >     var $name = 'Recipe';
> > > >     var $hasAndBelongsToMany = array(
> > > >         'Tag' =>
> > > >             array(
> > > >                  'className'              => 'Tag',
> > > >                  'joinTable'              => 'recipes_tags',
> > > >                  'with'                   =>
> > > > '',                          //<-- here it is
> > > >                 'foreignKey'             => 'recipe_id',
> > > >                 'associationForeignKey'  => 'tag_id',
> > > >                 'unique'                 => true,
> > > >                 'conditions'             => '',
> > > >                 'fields'                 => '',
> > > >                 'order'                  => '',
> > > >                 'limit'                  => '',
> > > >                 'offset'                 => '',
> > > >                 'finderQuery'            => '',
> > > >                 'deleteQuery'            => '',
> > > >                 'insertQuery'            => ''
> > > >             )
> > > >     );}
>
> > > > ?>
>
> > > > From the cookbook:
> > > > - with: Defines the name of the model for the join table. By default
> > > > CakePHP will auto-create a model for you. Using the example above it
> > > > would be called RecipesTag. By using this key you can override this
> > > > default name. The join table model can be used just like any "regular"
> > > > model to access the join table directly.
>
> > > > On 19 Gen, 14:43, Ernesto  wrote:
>
> > > > > Hello.
>
> > > > > i have 2 models: Customer and Order, linked together by a HABTM
> > > > > relationship that's working fine.
> > > > > the Join table (orders_customers) has the following structure:
>
> > > > > order_customer_id
> > > > > customer_id
> > > > > order_id
> > > > > field_A
> > > > > field_B
>
> > > > > field_A and field_B must be *100 everytime the data is loaded.
> > > > > How can i achieve this?
>
>
--~--~-~--~~~---~--~~
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: XML help

2009-01-21 Thread Webweave


Of course it depends on what you're trying to do, but ...

It's pretty much built in to Cake, all you need to do is set up the
routing and add code if you need it.

I wrote a bit about it here: 
http://blog.accuweaver.com/2008/12/04/cakephp-and-restful-web-services/


On Jan 21, 1:57 am, tjr88  wrote:
> HI,
>
> I am looking use the XML to update and pass information from my
> database. I have looked over the cake docs and googled abit but does
> anyone know of any good reasources to point me in the right
> direction??
>
> Thanks
--~--~-~--~~~---~--~~
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: validate 'minLength' for 'password' field

2009-01-21 Thread aranworld

Yes, you can do this.

In my User model, I have a series of validation rules for a field
called "new_passwd".

After this field is validated for things like minimum length I then
have it hashed into the string that gets stored in the database.

Here is a bakery article that can show how to do some validation on a
field that does not reflect a database column:

http://bakery.cakephp.org/articles/view/using-equalto-validation-to-compare-two-form-fields



On Jan 21, 8:21 am, adam  wrote:
> New question:
>
> Can you add validate data in your model that is absent from your
> database?  So if I try to solve this problem by creating a form field
> called password_confirm, would I be able to validate it in my model
> even though there isn't a corresponding spot in the database?
>
> On Jan 21, 10:08 am, adam  wrote:
>
> > I just searched the group, so nevermind this post.
>
> > On Jan 21, 9:49 am, adam  wrote:
>
> > > Could someone explain to me how to validate a 'password' field for
> > > 'minLength'?  I'm presuming that it is hashing the password before
> > > validating 'minLength'.  There must be some means to get around this.
>
> > > Thanks in advance,
> > > Adam
>
>
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



complex problem

2009-01-21 Thread medo

hi group

today i have really complex problem when i try to implement a site
with two back end interface one for the superadmin interface which
offered  to enter the global site config. and the second one is the
admin interface which offered to admin the site content and i didn't
use core.php using Configure::write('Routing.admin', 'admin') i use
the routes.php with these two lines

Router::connect('/superadmin/:controller/:action/*', array('prefix' =>
'superadmin'));
Router::connect('/admin/:controller/:action/*', array('prefix' =>
'admin'));

and after that i continue to implement the first controller which is
the posts controller and the problem appear when i try to add a link
in the admin_index.ctp view of the posts controller to the action add
of the same controller. the problem is when i use the verbose link the
route system give wrong link like this

[ admin_index.ctp of Posts controller ]
..
link('+ add new post',array
('controller'=>'Posts','action'=>'admin_add'))) ?>
..

the result link will be

/superadmin/posts/admin_add  [ wrong link ]

but when i rearrange the route line to become like this

Router::connect('/admin/:controller/:action/*', array('prefix' =>
'admin'));
Router::connect('/superadmin/:controller/:action/*', array('prefix' =>
'superadmin'));

i get the right link like below

/admin/posts/add

is there any solution to this problem which will i face it again when
i'll work with the superadmin interface

--~--~-~--~~~---~--~~
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: Multiple login pages using Auth?

2009-01-21 Thread Miles J

Have the homepage login forms action destination go to the users
login:

// homepage

--~--~-~--~~~---~--~~
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: Anyone built a forum system yet?

2009-01-21 Thread Miles J

Exactly, it would take just way too much logic on each page. I have to
check the state of new posts since last visit, plus also posts that
were unread before this visit, then mark certain things as read/
unread... etc, etc. Then finally serializing the array and storing it
in the db.

Larger text/data in a single row can cause huge load times, id rather
stick to the session like my current one is.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Not so elegant implementation of mysql SQL_CACHE

2009-01-21 Thread Websta*

We needed to implemnt mysql query cache in our querries in a few
places, and the first implmentation of this ended up being the
following:

http://pastebin.com/mb4f95ad

it was just whipped together quickly, and im not endorsing the use of
this code to everyone, just thought someone might be interested, or
someone might have a better/simpler or less hackish feeling solution.
but alas it provides what we wanted for now. comments welcome.

implement by adding SQL_CACHE to your fields param of your model
methods
--~--~-~--~~~---~--~~
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: Cheatsheet & API discrepancies

2009-01-21 Thread Gwoo

There are other posts on the list about the API generation. Doxygen is
not helping us anymore so we are working on the solution.
--~--~-~--~~~---~--~~
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: Using non-primary key for view

2009-01-21 Thread sparroah

I have solved my own problem.  The solution, for those as lost as I
was, lies in the Model::find function.  I recommend 
http://book.cakephp.org/view/449/find
for some light reading.  The solution in my case was to override the
Model::read( ) function in my Item AppModel.  Code follows:

function read($fields = null, $id = null)
{

  /* Clean up $id, make sure it's real
   * See line 998 of model.php as a reference. */
if ($id != null)
{
$this->id = $id;
}
$id = $this->id;
if (is_array($this->id))
{
$id = $this->id[0];
}
if ($id !== null && $id !== false)
{ /* $id works, lets find our Item... */
$find_parameters = array (
'conditions'=> array ('Item.itemid'=>$id),
'recursive'=>1,
'fields'=> array ('Item.itemid',
'Item.revision',
'Item.content',
'Item.type',
'Item.mimetype',
'Item.poster'
),
'order'=>'Item.revision',
'limit'=>1
);
$this->data = $this->find('first', $find_parameters);
return $this->data;
}
else
{ /* Oops! */
return false;
}
}

I had been playing around with Model::query( ), but this is much less
flexible, and introduces potential issues down the road (with DBMS
changes, table name changes, etc.)  Model::query( ) also does not
return the Array of records, but returns instead the array containing
the result set directly from the query.

In short, I should have RTFM about two hours earlier.

If anyone can think of a reason why this is not wise, or knows of a
better way of doing it, suggestions are always welcome.

Cheers!

./sparroah

On Jan 21, 10:05 am, sparroah  wrote:
> I have a database organized to do automatic versioning of entries.  My
> table looks like this:
>
> `id` int(10) unsigned NOT NULL auto_increment,
> `itemid` varchar(5) NOT NULL,
> `revision` int(10) unsigned NOT NULL,
> ...
>
> That being said, `id` is not used for anything in the application
> itself, but only for Database tasks.  The `itemid` field is the field
> I wish to use for selecting the item, with the understanding that I
> select the entry with the most recent revision.  I have no issues
> writing the SQL for this, but where I get lost is how I would set up
> CakePHP to retrieve this.  For example, if I have an entry
>
> `id` = 5,
> `itemid` = "A",
> `revision` = 2,
> ...
>
> I want the URL to look like this:
>
> http://example.com/items/view/A
>
> and nothttp://example.com/items/view/5.
>
> Is this at all possible?  The Database is from a legacy application
> from which we are migrating, which precludes me modifying its
> structure (at first, anyway.)  Any help here is greatly appreciated.
>
> ./sparroah

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



Cheatsheet & API discrepancies

2009-01-21 Thread Scott D

Can someone explain the discrepancies between the cheatsheet and API?
As an example, the cheatsheet (http://cakephp.org/files/Resources/
CakePHP-1.2-Cheatsheet.pdf) defines several methods on the Model class
- find(), delete(), deleteAll(), etc. - that are absent from the API
documentation for the Model class (http://api.cakephp.org/
class_model.html), including it's parent classes.

I'm new to Cake (obviously).  Have I overlooked something, or is the
API incomplete?

--~--~-~--~~~---~--~~
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: Security Notice for 1.2.0.7962, Using AuthComponent without SecurityComponent

2009-01-21 Thread Schreck

You could probably d/l fiddler2 (http://www.fiddler2.com/fiddler2/)
and use that to do whatever injections are needed. This app also works
with any browser that supports proxies and even works remotely.

On Jan 19, 7:38 am, Pyrite  wrote:
> Is there a way to test this CVE without Firefox? I do not have the
> option of Firefox at work. Only IE7.
>
> On Jan 16, 4:14 pm, Gwoo  wrote:
>
> > After the release of 1.2 Final, we received a lot of attention. Some
> > of this came in the form of a security concern. The issue could affect
> > sites relying on the AuthComponent for user authentication, without
> > the use of the SecurityComponent. Essentially, an attacker may be able
> > to obtain credentials as the first user of the system. If you are
> > interested in testing your site, you can use the SQL Inject Me plugin
> > for Firefox[1]
>
> > Along with several other bugs, this issue was fixed in the recently
> > released CakePHP 1.2.1.8004 Stable. We highly recommend that users
> > upgrade to this release.
>
> > A big thank you for all those who report these issues to us and allow
> > us to fix them.
>
> > Bake on,
> > CakePHP team
>
> > [1]https://addons.mozilla.org/en-US/firefox/addon/7597

--~--~-~--~~~---~--~~
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: Anyone built a forum system yet?

2009-01-21 Thread brian

On Tue, Jan 20, 2009 at 6:31 PM, mattmoy...@gmail.com
 wrote:
>
> Cookies/Session Vars. is the way to go for the read/unread threads.

Would you store every thread ID in the cookie? That'd soon become
rather unwieldy. Remember, we're talking about repeat visits, not just
within a single user session.

--~--~-~--~~~---~--~~
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: Anyone built a forum system yet?

2009-01-21 Thread brian

On Wed, Jan 21, 2009 at 12:43 AM, Brian Williams  wrote:
> not to step on toes but i'm not sure why it's such a problem storing that
> data in a db...
>
> if you want quick access to the data but not a zillion records make a hash,
> and store that hash in the db and a cookie.
>
> when the user logs in, read the hash and store into their session and save
> it in their cookie until they log out.

That seems like a good idea, but how would you get the thread IDs from
a hash? The only way I can see that working is if you hashed every
combination of thread IDs (plus whatever user-specific info you
previously hashed) and tested against what was stored in the cookie.
Obviously, that wouldn't be very efficient. What did you have in mind?

--~--~-~--~~~---~--~~
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: Anyone built a forum system yet?

2009-01-21 Thread brian

As I mentioned earlier, this wouldn't be accurate. A user can log in
but not read certain threads. Think of an email client--when I open
Thunderbird, I expect that any unread messages will remain in an
"unread" state regardless of when they were sent.

On Wed, Jan 21, 2009 at 8:39 AM, mark_story  wrote:
>
> Couldn't you just compare dates?  Compare the last time the person
> logged in with that of all the most recent posts.  Then in the session
> all you need to do is track which ones have been read, and unhighlight
> those in the view.  I don't think there is really a need to store this
> in the database.
>
> -Mark
>
> On Jan 20, 4:00 pm, Miles J  wrote:
>> What if there are like 1000+ unread threads, with thousands of users.
>> Why would I want to store all that information in the system. Plus I
>> would also have to extract the array from the database, remove indexes
>> depending on what threads they have read, update the db again, etc.
>>
>> Anyways, anyone have answers to my initial 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: controller not found..

2009-01-21 Thread brian

Instead of just returning something from that method, you could also
store info in the session to reflect the user's status.

On Wed, Jan 21, 2009 at 11:19 AM, vikas  wrote:
>
> Hello all..
>
> I have a problem...
>
> I have functionality called 'attendance for user'.
> When user login after logged in there is MarkIn and MarkOut button.
> when he clicks on MarkIn button, new entry will be placed in
> 'attendances' table for current date.
>
> My attendances table has a fileds given below:
> id
> user_id
> date
> timein
> timeout
> is_present
>
> And now when He clicked on MarkOut button, that entry will be
> updated..
>
> I want functionality that initially when user haven't markin, the
> markout button will be disabled. and once user markin, the markin
> button will become disabled and markout will become enabled.
> And if marked out then both button will become disable for today for
> that user.
>
> I have made element for attendance, so that buttons appear on all
> other pages. I have done that functionality using simple function
> given below. But this works for only on attendnace page on other page
> it will not work because that element will not get values for
> Attendancescontroller..
>
> I have tried component but still problem remains as it does not find
> Attendancescontroller...
>
> My coding in AttendancesController:
> function markInOut() {
>$mark = $this->Attendance->find('all',array(
>'conditions'=>(array(
>   
>  'Attendance.date'=>date("Y-m-d"),
>   
>  'Attendance.user_id'=>$this->Session->read('Auth.User.id')
>   
>  )
>   
>  ),
>'fields'=>(array(
>   
>  
> 'Attendance.id','Attendance.date','Attendance.timein','Attendance.timeout','Attendance.is_present','Attendance.user_id')
>   
>  )
>)
>);
>
>if(count($mark) == 0) {
>return 'start';
>}
>$mark = $this->Attendance->find('all',array(
>'conditions'=>(array(
>   
>  'Attendance.date'=>date("Y-m-d"),
>   
>  'Attendance.user_id'=>$this->Session->read('Auth.User.id'),
>   
>  'Attendance.is_present'=>'1',
>   
>  )
>   
>  ),
>'fields'=>(array(
>   
>  
> 'Attendance.id','Attendance.date','Attendance.timein','Attendance.timeout','Attendance.is_present','Attendance.user_id')
>   
>  )
>)
>);
>if(count($mark) > 0) {
>return 'end';
>}
>else {
>return 'process';
>}
>}
>
>
> SO help me out.
> If need more clearification on the problem then also reply...
>
>
> >
>

--~--~-~--~~~---~--~~
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: Read Excel files

2009-01-21 Thread Martin Westin


I have used http://sourceforge.net/projects/phpexcelreader
It is quite basic (and therefore lightweight) but does the trick so
far.

Example from the dist:

$data = new Spreadsheet_Excel_Reader();
$data->read('jxlrwtest.xls');
for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {
for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) {
echo "\"".$data->sheets[0]['cells'][$i][$j]."\",";
}
echo "\n";

}



On Jan 21, 6:21 pm, nAcho  wrote:
> Hi, I've managed to write excel files using an article in the bakery.
>
> Now, I'd like to importa some data from some Excel files. I couldn't
> find an Excel Reader or anything like it. Is there something I could
> use to this purpose?
>
> Note: I don't want to make people save xls files into csv (at least
> for now...)
>
> Thanks!
>
> Ignacio
> (Cake noob)
--~--~-~--~~~---~--~~
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: Read Excel files

2009-01-21 Thread brian

Have you looked at PHPExcel?

On Wed, Jan 21, 2009 at 12:21 PM, nAcho  wrote:
>
> Hi, I've managed to write excel files using an article in the bakery.
>
> Now, I'd like to importa some data from some Excel files. I couldn't
> find an Excel Reader or anything like it. Is there something I could
> use to this purpose?
>
> Note: I don't want to make people save xls files into csv (at least
> for now...)
>
> Thanks!
>
> Ignacio
> (Cake noob)
>
> >
>

--~--~-~--~~~---~--~~
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: Dynamic Model Call

2009-01-21 Thread brian

Try $this->AreaInfo->{$model_name}->find(...)

On Wed, Jan 21, 2009 at 12:33 AM, wmonou  wrote:
>
> Helo there i am trying to call model from a variable
>
> let say that i have a code is like this:
>
>// $model_name is a string
>// bind necessary model
>if(!empty($model_name)){
>$this->AreaInfo->bindModel(
>array(
>'belongsTo'=>array(
>$model_name => array(
>'className' => $model_name,
>'foreignKey' => 'reference_id'
>)
>)
>)
>);
>}
>
>$model_data = $this->AreaInfo->$model_name->find('list');// **
> this is my question
>print_r($model_data);
>
> the $model_data variable now is not empty, but i got something like
> this :
>
> Array
> (
>[1] => 1
>[2] => 2
>[3] => 3
>[4] => 4
>[5] => 5
>[6] => 6
>[7] => 7
>[8] => 8
>[9] => 9
>[10] => 10
>[11] => 11
>[12] => 12
>[13] => 13
>[14] => 14
>[15] => 15
>[16] => 16
>[17] => 17
>[18] => 18
>[19] => 19
>[20] => 20
> )
>
> Fatal error: Cannot access empty property in {some_directories_path}
> \app\controllers\areas_controller.php on line **
>
> is it possible to do such a thing like above? if yes or no please let
> me know with your sugesstion :) ...
>
> >
>

--~--~-~--~~~---~--~~
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: Query String

2009-01-21 Thread brian

Have a look at $this->params. Use isset() to test that the param is
there. You might want to further test the values, depending on your
neds.

On Wed, Jan 21, 2009 at 8:23 AM, Cjo  wrote:
>
> Hi all,
>
> I have to give access to my data from database using url.. For this i
> have written a controller which in turn returns the data in XML
> format. This part was actually easy. This url also contains query
> string with which i have to get the data. Here is where i am stuck.
>
> Let the three parameters coming as query string be LAB, FROMDATE and
> TODATE. How can i know from the url that these 3 parameters are
> present in the query string. All the 3 parameters must be there to
> retrieve the data. So if there is any one missing I have to through an
> error.
>
> I have validated if the parameter is in the query string and its value
> is empty.(http://localhost/spicesboard/labAnalysis/intimationList/?
> Lab=&FromDate=2&ToDate=3)
>
> I have to validate if the query string does not contain the parameter
> itself. Ex(http://localhost/spicesboard/labAnalysis/intimationList/?
> ToDate=3)
>
>
>
> Regards
> Sijo Jose C
>
>
>
> >
>

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



Read Excel files

2009-01-21 Thread nAcho

Hi, I've managed to write excel files using an article in the bakery.

Now, I'd like to importa some data from some Excel files. I couldn't
find an Excel Reader or anything like it. Is there something I could
use to this purpose?

Note: I don't want to make people save xls files into csv (at least
for now...)

Thanks!

Ignacio
(Cake noob)

--~--~-~--~~~---~--~~
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: How to count users login?

2009-01-21 Thread Alexandru Ciobanu

Henrique Machado wrote:
> I need to provide an access count to my users
>
> Like "This is you 4 time here"
>
> I'm using the Auth component, my doubt is where put my
>
> $this->User->updateAll(array('User.access'=> 'User.access+1'), 
> array('User.id' => $user['User']['id']));
>
> I need to be sure that the user is logged successfull to increment the 
> access.
>
Perhaps an increment behavior will help you.

http://bakery.cakephp.org/articles/view/increment-behavior

--~--~-~--~~~---~--~~
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 count users login?

2009-01-21 Thread Henrique Machado
I need to provide an access count to my users

Like "This is you 4 time here"

I'm using the Auth component, my doubt is where put my

$this->User->updateAll(array('User.access'=> 'User.access+1'),
array('User.id' => $user['User']['id']));

I need to be sure that the user is logged successfull to increment the
access.

Ty

--~--~-~--~~~---~--~~
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: How did they do that?

2009-01-21 Thread bee

Great!  I have just started exploring the AJAX Helper yesterday. Thank
you.

On Jan 21, 7:45 am, Nate  wrote:
> It's all jQuery, as written by Marc Grabanski.  Check 
> outhttp://cakephp.org/js/common.js
>
> On Jan 20, 11:13 pm, bee  wrote:
>
> > Hi I am a newbie to cakephp and I am dying to know how to implement
> > one of the main menus on cakephp main page:
> > I have cakephp setup and have implemented one site. Now, I am trying
> > out advanced features (ajax, etc)
>
> > So, my question is:
> > Onhttp://cakephp.org/atthe top portion of the page, a menu lists:
> > (it is almost flash like)
>
> > Get It Now
> > Hot Features
> > Learn
> > Interact
> > ...
>
> > with two arrows allowing the user to quickly move to the next section
> > to read.
>
> > That is cool. I want to do that Please let me know the best way to
> > implement this!
> > Thanks,
> > Christy

--~--~-~--~~~---~--~~
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: validate 'minLength' for 'password' field

2009-01-21 Thread adam

New question:

Can you add validate data in your model that is absent from your
database?  So if I try to solve this problem by creating a form field
called password_confirm, would I be able to validate it in my model
even though there isn't a corresponding spot in the database?



On Jan 21, 10:08 am, adam  wrote:
> I just searched the group, so nevermind this post.
>
> On Jan 21, 9:49 am, adam  wrote:
>
> > Could someone explain to me how to validate a 'password' field for
> > 'minLength'?  I'm presuming that it is hashing the password before
> > validating 'minLength'.  There must be some means to get around this.
>
> > Thanks in advance,
> > Adam
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



controller not found..

2009-01-21 Thread vikas

Hello all..

I have a problem...

I have functionality called 'attendance for user'.
When user login after logged in there is MarkIn and MarkOut button.
when he clicks on MarkIn button, new entry will be placed in
'attendances' table for current date.

My attendances table has a fileds given below:
id
user_id
date
timein
timeout
is_present

And now when He clicked on MarkOut button, that entry will be
updated..

I want functionality that initially when user haven't markin, the
markout button will be disabled. and once user markin, the markin
button will become disabled and markout will become enabled.
And if marked out then both button will become disable for today for
that user.

I have made element for attendance, so that buttons appear on all
other pages. I have done that functionality using simple function
given below. But this works for only on attendnace page on other page
it will not work because that element will not get values for
Attendancescontroller..

I have tried component but still problem remains as it does not find
Attendancescontroller...

My coding in AttendancesController:
function markInOut() {
$mark = $this->Attendance->find('all',array(
'conditions'=>(array(

'Attendance.date'=>date("Y-m-d"),

'Attendance.user_id'=>$this->Session->read('Auth.User.id')

)

),
'fields'=>(array(

'Attendance.id','Attendance.date','Attendance.timein','Attendance.timeout','Attendance.is_present','Attendance.user_id')

)
)
);

if(count($mark) == 0) {
return 'start';
}
$mark = $this->Attendance->find('all',array(
'conditions'=>(array(

'Attendance.date'=>date("Y-m-d"),

'Attendance.user_id'=>$this->Session->read('Auth.User.id'),

'Attendance.is_present'=>'1',

)

),
'fields'=>(array(

'Attendance.id','Attendance.date','Attendance.timein','Attendance.timeout','Attendance.is_present','Attendance.user_id')

)
)
);
if(count($mark) > 0) {
return 'end';
}
else {
return 'process';
}
}


SO help me out.
If need more clearification on the problem then also reply...


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



Anyone subscribe to PHP Architect?

2009-01-21 Thread aranworld

PHP Architect seems somewhat centered on the Zend Framework, so I'm
wondering if it is a worthwhile magazine for someone whose main focus
is CakePHP.

So, if you subscribe to it, do you find it worth the money and time
spent reading it?


--~--~-~--~~~---~--~~
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: validate 'minLength' for 'password' field

2009-01-21 Thread adam

I just searched the group, so nevermind this post.

On Jan 21, 9:49 am, adam  wrote:
> Could someone explain to me how to validate a 'password' field for
> 'minLength'?  I'm presuming that it is hashing the password before
> validating 'minLength'.  There must be some means to get around this.
>
> Thanks in advance,
> Adam
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



validate 'minLength' for 'password' field

2009-01-21 Thread adam

Could someone explain to me how to validate a 'password' field for
'minLength'?  I'm presuming that it is hashing the password before
validating 'minLength'.  There must be some means to get around this.

Thanks in advance,
Adam
--~--~-~--~~~---~--~~
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: How did they do that?

2009-01-21 Thread Nate

It's all jQuery, as written by Marc Grabanski.  Check out
http://cakephp.org/js/common.js

On Jan 20, 11:13 pm, bee  wrote:
> Hi I am a newbie to cakephp and I am dying to know how to implement
> one of the main menus on cakephp main page:
> I have cakephp setup and have implemented one site. Now, I am trying
> out advanced features (ajax, etc)
>
> So, my question is:
> Onhttp://cakephp.org/at the top portion of the page, a menu lists:
> (it is almost flash like)
>
> Get It Now
> Hot Features
> Learn
> Interact
> ...
>
> with two arrows allowing the user to quickly move to the next section
> to read.
>
> That is cool. I want to do that Please let me know the best way to
> implement this!
> Thanks,
> Christy
--~--~-~--~~~---~--~~
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: Error when including prototype and scriptaculous in layout template

2009-01-21 Thread mrg

On Oct 12 2008, 12:37 am, ORCC  wrote:

[..trimmed...]

>
> The page seems to load correctly, altough the Firefox's error console
> issues the following errors:
>
> Error: syntax error
> Source File:http://MY_DOMAIN/gmg/js/sound.js
> Línea: 1
> Código fuente:
>  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
>
> The code is a missing_controller page generate by cake in the
> scriptaculous loading, because the "JS" controller is missing. (This
> is the globlal object in scriptaculous that loads some scripts like
> sound, dragdrop and others)
>
> What is the solution for this trouble?


I have exactly the same problem.

In my view this generated the error:

link('prototype',false);
   echo $javascript->link('scriptaculous',false); ?>

But this was OK:

link('prototype');
   echo $javascript->link('scriptaculous'); ?>

Inline vs in header...

I am using v1.2 of CakePHP.

Does anyone have any ideas?  Not sure where it is getting sound.js
from
But functionally the page works fine.

matt

--~--~-~--~~~---~--~~
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 did they do that?

2009-01-21 Thread bee

Hi I am a newbie to cakephp and I am dying to know how to implement
one of the main menus on cakephp main page:
I have cakephp setup and have implemented one site. Now, I am trying
out advanced features (ajax, etc)

So, my question is:
On http://cakephp.org/ at the top portion of the page, a menu lists:
(it is almost flash like)

Get It Now
Hot Features
Learn
Interact
...

with two arrows allowing the user to quickly move to the next section
to read.

That is cool. I want to do that Please let me know the best way to
implement this!
Thanks,
Christy


--~--~-~--~~~---~--~~
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: How do I use "find" to retreive data from multiple tables

2009-01-21 Thread Tim Banks

Try binding the model temporarily like this:

//temporary binding to the user table to query on a user
$this->Site->bindModel(array('hasOne' => array('SiteUser')));

I have used this and it works in similar situations.

-Tim

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



Using non-primary key for view

2009-01-21 Thread sparroah

I have a database organized to do automatic versioning of entries.  My
table looks like this:

`id` int(10) unsigned NOT NULL auto_increment,
`itemid` varchar(5) NOT NULL,
`revision` int(10) unsigned NOT NULL,
...


That being said, `id` is not used for anything in the application
itself, but only for Database tasks.  The `itemid` field is the field
I wish to use for selecting the item, with the understanding that I
select the entry with the most recent revision.  I have no issues
writing the SQL for this, but where I get lost is how I would set up
CakePHP to retrieve this.  For example, if I have an entry

`id` = 5,
`itemid` = "A",
`revision` = 2,
...

I want the URL to look like this:

http://example.com/items/view/A

and not http://example.com/items/view/5.

Is this at all possible?  The Database is from a legacy application
from which we are migrating, which precludes me modifying its
structure (at first, anyway.)  Any help here is greatly appreciated.


./sparroah

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



Can't use the formHelper with in

2009-01-21 Thread maeto-lay

I try to change all of my pages to use the view caching feature of
cakephp.
The problem occurred when I try to useing the cache in the page that
have
formHelper.

This is my code.


create('User');
echo $form->input('User.username');
echo $form->end('submit');
?>


And when I refresh the page to see if cache working I found this
error.

Notice (8): Undefined property:  stdClass::$model
[CORE\cake\libs\view\helper.php, line 328]
Notice (8): Undefined property:  stdClass::$association
[CORE\cake\libs\view\helper.php, line 361]
Notice (8): Undefined property:  stdClass::$field
[CORE\cake\libs\view\helper.php, line 361]

Fatal error: Call to a member function entity() on a non-object in
C:\xampplite\htdocscontainer\htdocs\cake\libs\view\helper.php on line
316

I don't want to hand code all the form in my web so if anyone can help
me
please light me up.


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



fatal error when scaffolding a many to many relationship

2009-01-21 Thread laurent henocque

Hi,
I have the following problem:
Fatal error: Cannot access empty property in /Users/lo/Devt/eclipse/
workspace/baketest/cake/libs/model/model.php on line 2675

this occurs with the following declaration (the posts_tags table
exists with correct fields)


var $hasAndBelongsToMany = array(
'Tag' =>
array(
 'className'  => 'Tag',
 'joinTable'  => 'posts_tags',
 'with'   => '',
'foreignKey' => 'post_id',
'associationForeignKey'  => 'tag_id',
'unique' => true,
'conditions' => '',
'fields' => '',
'order'  => '',
'limit'  => '',
'offset' => '',
'finderQuery'=> '',
'deleteQuery'=> '',
'insertQuery'=> ''
)
);

any hint please?
Cheers
Laurent

--~--~-~--~~~---~--~~
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: Anyone built a forum system yet?

2009-01-21 Thread Brian Williams
not to step on toes but i'm not sure why it's such a problem storing that
data in a db...

if you want quick access to the data but not a zillion records make a hash,
and store that hash in the db and a cookie.

when the user logs in, read the hash and store into their session and save
it in their cookie until they log out.

when you read and process the hash you'll have the read threads which you
can use to differentiate the read/unread threads for the indicator image.

when they view a unread thread add it to the hash and update the db and the
session, and write the cookie.

just my 2 cent


On Tue, Jan 20, 2009 at 9:21 PM, Miles J  wrote:

>
> Sigh, man you guys are taking this way out of context.
>
> Perhaps answer the other questions that I asked.
> >
>

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



Multiple login pages using Auth?

2009-01-21 Thread yodi

Hello,

I'm thinking about multiple login pages using Auth. 

example there two pages login, one in home page and login page
(usual: /users/login).

if users login from home, it's not redirect to login page and still in
home page with error validation. 

Then if users login from login page, they will still on login page with
error validation too.

Anyone have this problems before?

maybe someone can give some solution please?

Thanks.


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



Dynamic Model Call

2009-01-21 Thread wmonou

Helo there i am trying to call model from a variable

let say that i have a code is like this:

// $model_name is a string
// bind necessary model
if(!empty($model_name)){
$this->AreaInfo->bindModel(
array(
'belongsTo'=>array(
$model_name => array(
'className' => $model_name,
'foreignKey' => 'reference_id'
)
)
)
);
}

$model_data = $this->AreaInfo->$model_name->find('list');// **
this is my question
print_r($model_data);

the $model_data variable now is not empty, but i got something like
this :

Array
(
[1] => 1
[2] => 2
[3] => 3
[4] => 4
[5] => 5
[6] => 6
[7] => 7
[8] => 8
[9] => 9
[10] => 10
[11] => 11
[12] => 12
[13] => 13
[14] => 14
[15] => 15
[16] => 16
[17] => 17
[18] => 18
[19] => 19
[20] => 20
)

Fatal error: Cannot access empty property in {some_directories_path}
\app\controllers\areas_controller.php on line **

is it possible to do such a thing like above? if yes or no please let
me know with your sugesstion :) ...

--~--~-~--~~~---~--~~
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: Anyone built a forum system yet?

2009-01-21 Thread mattmoy...@gmail.com

Cookies/Session Vars. is the way to go for the read/unread threads.
Wouldn't make sense to put that much load on the database for such a
non-essential task.  Just use a little javascript to make the unread
thread titles bold or whatever else you to do.

--~--~-~--~~~---~--~~
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 best way to use named parameters as search conditions for pagination?

2009-01-21 Thread dr. Hannibal Lecter

You're going in the right direction. Your function will only use the
conditions for fields in your table. It doesn't really matter if your
user specifies additional "conditions" because they will be ignored.

I haven't tried it, but I assume you could always make a whitelist of
allowed params and unset everything else. Just don't forget to
sanitize them.. :-)

On Jan 21, 3:20 pm, "die...@be"  wrote:
> Hi all,
> I want to use pagination, but also named parameters to form conditions
> to restrict my resultset.
> Example:
> Customer hasmany contract, contract belongsTo Customer (foreign key
> customer_id)
>
> I want to be able to paginate contracts, but also only view
> (paginated) the contracts of a certain customer.
> Url's would be something like this:
> /contracts/index/customer_id:
> 1                                                         # only look
> for records where customer_id = 1
> /contracts/index/page:1/sort:customer_id/
> direction:asc/                      # some paginated view
> /contracts/index/page:1/sort:customer_id/direction:asc/customer_id:1 #
> pagination + search condititon combined
>
> My first idea: since $this->passedArgs is an array of key-value pairs
> of the named parameters, I can directly use it to specify the
> conditions, like so:
> $this->set('contracts', $this->paginate('Contract',$this->passedArgs));
>
> The problem with this is that the user can pass any parameter he want,
> thus forming invalid queries.  In fact the parameters from the
> paginator end up in my conditions also and make the query invalid.
>
> So.. I should filter the $this->passedArgs to only use the entries
> that match a column of my model, right?
> So I came up with this:http://bin.cakephp.org/view/737267546
> This is better, but still the user can specify any value.  Is there
> any way to validate the arguments before using them as conditions?
>
> Or am I just looking to far, is there a more elegant way to handle
> this?
> Thanks,
> Dieter
--~--~-~--~~~---~--~~
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: How can I force www. to always be in my domain name?

2009-01-21 Thread Smelly_Eddie

In my opinion you should be doing just the opposite.

WWW was used when computers needed the sub.domain to be aware of what
type of content they were about to receive.

Since web-pages today are becoming RIA and browsers are so robust the
need is deprecated, and I and may others argue that www should be
deprecated to.

Users that visit any of my domains using the www prefix will be
rerouted to the top domain, without the prefix.  Google allows
webmasters to specify this as well so it will only crawl and show my
pages as top-domain.org.





An interesting site that takes my side;
http://no-www.org/

On Jan 21, 2:30 am, Jon Bennett  wrote:
> Hi Parris,
>
> >  > 
> >  >    RewriteEngine on
> >  >         RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
> >  >         RewriteCond %{HTTPS}s ^on(s)|off
> >  >         RewriteRule ^(.*)$ http%1://www.domain.com/$1[R=301,QSA,L]
>
> >  >         RewriteRule    ^$ app/webroot/    [L]
> >  >         RewriteRule    (.*) app/webroot/$1 [L]
> >  > 
>
> I need to accomplish something similar, I don't need to worry about
> SSL, but I do have 3 domains, so far I have:
>
> RewriteCond %{HTTP_HOST} !^www.domain1.co.uk$[NC]
> RewriteCond %{HTTP_HOST} !^www.domain2.co.uk$[NC]
> RewriteRule ^(.*)$http://www.maindomain.co.uk/$1[R=301,QSA,L]
>
> RewriteRule    ^$ app/webroot/    [L]
> RewriteRule    (.*) app/webroot/$1 [L]
>
> but this isn't doing anything, except the normal cake rewrite, any ideas?
>
> Cheers,
>
> Jon
>
> --
>
> jon bennett
> w:http://www.jben.net/
> iChat (AIM): jbendotnet Skype: jon-bennett
--~--~-~--~~~---~--~~
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: Format fields in the european way

2009-01-21 Thread leo

Btw, the code you link to in afterFind is a dead link.

On Jan 21, 3:46 pm, leo  wrote:
> Sorry. I just got the impression you were reinventing the wheel. PHP
> will do the formatting for you.
>
> On Jan 21, 3:26 pm, Ernesto  wrote:
>
> > thx for the resp but that's not my problem. :)
>
> > i'm getting some errors like
> > - data from related models not being formatted
> > - data from related models being formatted many times
>
> > On 20 Gen, 17:18, leo  wrote:
>
> > > I use srttotime() and pass the result to date() using format 'c' in
> > > PHP5 or 'Y-m-d' in PHP4 viz:
> > >     date('Y-m-d', strtotime($date))
> > > $date will need to be formatted like "10 September 2000" - I don't
> > > think the month number will work, but look at the PHP manual for more
> > > info.
>
> > > This code I use in the controller::edit or controller::add functions
> > > like:
> > >                 if (!empty($this->data)) {
> > >                         $this->data['Event']['start_date'] = date
> > > ('c' ,strtotime($this->data['Event']['start_date']));
> > >                 --snip--
>
> > > On Jan 20, 4:25 pm, Ernesto  wrote:
>
> > > > Hello.
>
> > > > i'm writing an app for my little business. i'm using CakePHP + MySQL.
>
> > > > My problem are the DB fields formatted in US way. For example
> > > > - dates in MySQL must be written "-MM-DD" when we usually use "DD/
> > > > MM/".
> > > > - US float notation uses dot (.) instead of comma (,) as decimal
> > > > separator.
>
> > > > i wrote some code to resolve that "issue" in both ways (read/save) but
> > > > i'm getting some errors, especially on related models.
>
> > > > @@ here's my DB schema
>
> > > > Person --> HABTM (persons_articles) --> Article --> BELONGSTO -->
> > > > Article_code
>
> > > > @@ here's the error
>
> > > > Article_code contains a "datetime" field (Article_code.Created).
>
> > > > when the page //Cake/persons/details is loaded the
> > > > Article_code.Created gets formatted many times.
>
> > > > @@ here's the incriminated code:
>
> > > > class AppModel extends Model {
>
> > > >         function afterFind($results, $primary = false) {
> > > >                 //the code in this function can be found at
> > > >                 
> > > > //http://groups.google.com/group/cake-php/browse_thread/thread/
> > > > 32ab9f8baed4a05a/062678e92b080f18
> > > >                 //i just renamed the "doAfterFind" function to 
> > > > "stdFormat"
> > > >                 //thx @ the original author of that code.
> > > >         }
>
> > > >         function beforeSave() {
> > > >                 //i convert the data from EU to US so i can save data 
> > > > in database
> > > >                 $this->data = $this->stdFormat($this->data, "ITAtoUS);
> > > >                 return true;
>
> > > >         }
>
> > > >         function stdFormat($data, $format) {
> > > >                 //standard formats, applied to every field of every 
> > > > model.
> > > >                 //this function works on flat arrays (field => value)
> > > >                 foreach ($data as $fieldName => &$value) {
> > > >                         if ($this->hasField($fieldName)) {
> > > >                                 switch 
> > > > ($this->getColumnType($fieldName)) {
> > > >                                         case "datetime":
> > > >                                                 list($date, $time) = 
> > > > explode(" ", $value);
> > > >                                         case "date":
> > > >                                                 switch ($format) {
> > > >                                                         case "UStoITA"
> > > >                                                                 
> > > > list($y, $m, $d) = explode("-", $data);
> > > >                                                                 $value 
> > > > = trim("$d/$m/$y $time");
> > > >                                                         break;
> > > >                                                         case "ITAtoUS":
> > > >                                                                 
> > > > list($g, $m, $a) = explode("/", $data);
> > > >                                                                 $value 
> > > > = trim("$y-$m-$d $time");
> > > >                                                         break;
> > > >                                                 }
> > > >                                         break;
> > > >                                         case "float":
> > > >                                                 switch ($format) {
> > > >                                                         case "UStoITA":
> > > >                                                                 
> > > > //sostituisco il separatore decimale (da punto a virgola)
> > > >                                                                 $value 
> > > > = str_replace(".", ",", $value);
> > > >                                                         break;
> > > >        

Re: Format fields in the european way

2009-01-21 Thread leo

Sorry. I just got the impression you were reinventing the wheel. PHP
will do the formatting for you.

On Jan 21, 3:26 pm, Ernesto  wrote:
> thx for the resp but that's not my problem. :)
>
> i'm getting some errors like
> - data from related models not being formatted
> - data from related models being formatted many times
>
> On 20 Gen, 17:18, leo  wrote:
>
> > I use srttotime() and pass the result to date() using format 'c' in
> > PHP5 or 'Y-m-d' in PHP4 viz:
> >     date('Y-m-d', strtotime($date))
> > $date will need to be formatted like "10 September 2000" - I don't
> > think the month number will work, but look at the PHP manual for more
> > info.
>
> > This code I use in the controller::edit or controller::add functions
> > like:
> >                 if (!empty($this->data)) {
> >                         $this->data['Event']['start_date'] = date
> > ('c' ,strtotime($this->data['Event']['start_date']));
> >                 --snip--
>
> > On Jan 20, 4:25 pm, Ernesto  wrote:
>
> > > Hello.
>
> > > i'm writing an app for my little business. i'm using CakePHP + MySQL.
>
> > > My problem are the DB fields formatted in US way. For example
> > > - dates in MySQL must be written "-MM-DD" when we usually use "DD/
> > > MM/".
> > > - US float notation uses dot (.) instead of comma (,) as decimal
> > > separator.
>
> > > i wrote some code to resolve that "issue" in both ways (read/save) but
> > > i'm getting some errors, especially on related models.
>
> > > @@ here's my DB schema
>
> > > Person --> HABTM (persons_articles) --> Article --> BELONGSTO -->
> > > Article_code
>
> > > @@ here's the error
>
> > > Article_code contains a "datetime" field (Article_code.Created).
>
> > > when the page //Cake/persons/details is loaded the
> > > Article_code.Created gets formatted many times.
>
> > > @@ here's the incriminated code:
>
> > > class AppModel extends Model {
>
> > >         function afterFind($results, $primary = false) {
> > >                 //the code in this function can be found at
> > >                 
> > > //http://groups.google.com/group/cake-php/browse_thread/thread/
> > > 32ab9f8baed4a05a/062678e92b080f18
> > >                 //i just renamed the "doAfterFind" function to "stdFormat"
> > >                 //thx @ the original author of that code.
> > >         }
>
> > >         function beforeSave() {
> > >                 //i convert the data from EU to US so i can save data in 
> > > database
> > >                 $this->data = $this->stdFormat($this->data, "ITAtoUS);
> > >                 return true;
>
> > >         }
>
> > >         function stdFormat($data, $format) {
> > >                 //standard formats, applied to every field of every model.
> > >                 //this function works on flat arrays (field => value)
> > >                 foreach ($data as $fieldName => &$value) {
> > >                         if ($this->hasField($fieldName)) {
> > >                                 switch ($this->getColumnType($fieldName)) 
> > > {
> > >                                         case "datetime":
> > >                                                 list($date, $time) = 
> > > explode(" ", $value);
> > >                                         case "date":
> > >                                                 switch ($format) {
> > >                                                         case "UStoITA"
> > >                                                                 list($y, 
> > > $m, $d) = explode("-", $data);
> > >                                                                 $value = 
> > > trim("$d/$m/$y $time");
> > >                                                         break;
> > >                                                         case "ITAtoUS":
> > >                                                                 list($g, 
> > > $m, $a) = explode("/", $data);
> > >                                                                 $value = 
> > > trim("$y-$m-$d $time");
> > >                                                         break;
> > >                                                 }
> > >                                         break;
> > >                                         case "float":
> > >                                                 switch ($format) {
> > >                                                         case "UStoITA":
> > >                                                                 
> > > //sostituisco il separatore decimale (da punto a virgola)
> > >                                                                 $value = 
> > > str_replace(".", ",", $value);
> > >                                                         break;
> > >                                                         case "ITAtoUS":
> > >                                                                 $value = 
> > > str_replace(",", ".", $value);
> > >                                                         break;
> > >                             

Re: Format fields in the european way

2009-01-21 Thread Ernesto

thx for the resp but that's not my problem. :)

i'm getting some errors like
- data from related models not being formatted
- data from related models being formatted many times

On 20 Gen, 17:18, leo  wrote:
> I use srttotime() and pass the result to date() using format 'c' in
> PHP5 or 'Y-m-d' in PHP4 viz:
>     date('Y-m-d', strtotime($date))
> $date will need to be formatted like "10 September 2000" - I don't
> think the month number will work, but look at the PHP manual for more
> info.
>
> This code I use in the controller::edit or controller::add functions
> like:
>                 if (!empty($this->data)) {
>                         $this->data['Event']['start_date'] = date
> ('c' ,strtotime($this->data['Event']['start_date']));
>                 --snip--
>
> On Jan 20, 4:25 pm, Ernesto  wrote:
>
>
>
> > Hello.
>
> > i'm writing an app for my little business. i'm using CakePHP + MySQL.
>
> > My problem are the DB fields formatted in US way. For example
> > - dates in MySQL must be written "-MM-DD" when we usually use "DD/
> > MM/".
> > - US float notation uses dot (.) instead of comma (,) as decimal
> > separator.
>
> > i wrote some code to resolve that "issue" in both ways (read/save) but
> > i'm getting some errors, especially on related models.
>
> > @@ here's my DB schema
>
> > Person --> HABTM (persons_articles) --> Article --> BELONGSTO -->
> > Article_code
>
> > @@ here's the error
>
> > Article_code contains a "datetime" field (Article_code.Created).
>
> > when the page //Cake/persons/details is loaded the
> > Article_code.Created gets formatted many times.
>
> > @@ here's the incriminated code:
>
> > class AppModel extends Model {
>
> >         function afterFind($results, $primary = false) {
> >                 //the code in this function can be found at
> >                 
> > //http://groups.google.com/group/cake-php/browse_thread/thread/
> > 32ab9f8baed4a05a/062678e92b080f18
> >                 //i just renamed the "doAfterFind" function to "stdFormat"
> >                 //thx @ the original author of that code.
> >         }
>
> >         function beforeSave() {
> >                 //i convert the data from EU to US so i can save data in 
> > database
> >                 $this->data = $this->stdFormat($this->data, "ITAtoUS);
> >                 return true;
>
> >         }
>
> >         function stdFormat($data, $format) {
> >                 //standard formats, applied to every field of every model.
> >                 //this function works on flat arrays (field => value)
> >                 foreach ($data as $fieldName => &$value) {
> >                         if ($this->hasField($fieldName)) {
> >                                 switch ($this->getColumnType($fieldName)) {
> >                                         case "datetime":
> >                                                 list($date, $time) = 
> > explode(" ", $value);
> >                                         case "date":
> >                                                 switch ($format) {
> >                                                         case "UStoITA"
> >                                                                 list($y, 
> > $m, $d) = explode("-", $data);
> >                                                                 $value = 
> > trim("$d/$m/$y $time");
> >                                                         break;
> >                                                         case "ITAtoUS":
> >                                                                 list($g, 
> > $m, $a) = explode("/", $data);
> >                                                                 $value = 
> > trim("$y-$m-$d $time");
> >                                                         break;
> >                                                 }
> >                                         break;
> >                                         case "float":
> >                                                 switch ($format) {
> >                                                         case "UStoITA":
> >                                                                 
> > //sostituisco il separatore decimale (da punto a virgola)
> >                                                                 $value = 
> > str_replace(".", ",", $value);
> >                                                         break;
> >                                                         case "ITAtoUS":
> >                                                                 $value = 
> > str_replace(",", ".", $value);
> >                                                         break;
> >                                                 }
> >                                         break;
> >                                 }
> >                         }
> >                 }
> >                 $data = modelFormat($data, $format);
> >                 return $data;
> >         }
>
> >         function modelFormat($data, $format) {

The best way to use named parameters as search conditions for pagination?

2009-01-21 Thread die...@be

Hi all,
I want to use pagination, but also named parameters to form conditions
to restrict my resultset.
Example:
Customer hasmany contract, contract belongsTo Customer (foreign key
customer_id)

I want to be able to paginate contracts, but also only view
(paginated) the contracts of a certain customer.
Url's would be something like this:
/contracts/index/customer_id:
1 # only look
for records where customer_id = 1
/contracts/index/page:1/sort:customer_id/
direction:asc/  # some paginated view
/contracts/index/page:1/sort:customer_id/direction:asc/customer_id:1 #
pagination + search condititon combined

My first idea: since $this->passedArgs is an array of key-value pairs
of the named parameters, I can directly use it to specify the
conditions, like so:
$this->set('contracts', $this->paginate('Contract',$this-
>passedArgs));
The problem with this is that the user can pass any parameter he want,
thus forming invalid queries.  In fact the parameters from the
paginator end up in my conditions also and make the query invalid.

So.. I should filter the $this->passedArgs to only use the entries
that match a column of my model, right?
So I came up with this: http://bin.cakephp.org/view/737267546
This is better, but still the user can specify any value.  Is there
any way to validate the arguments before using them as conditions?

Or am I just looking to far, is there a more elegant way to handle
this?
Thanks,
Dieter
--~--~-~--~~~---~--~~
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: Anyone built a forum system yet?

2009-01-21 Thread mark_story

Couldn't you just compare dates?  Compare the last time the person
logged in with that of all the most recent posts.  Then in the session
all you need to do is track which ones have been read, and unhighlight
those in the view.  I don't think there is really a need to store this
in the database.

-Mark

On Jan 20, 4:00 pm, Miles J  wrote:
> What if there are like 1000+ unread threads, with thousands of users.
> Why would I want to store all that information in the system. Plus I
> would also have to extract the array from the database, remove indexes
> depending on what threads they have read, update the db again, etc.
>
> Anyways, anyone have answers to my initial 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: Trying to update a controller from a different model...

2009-01-21 Thread mark_story

Dude, you only waited 2hrs. Chill out. This is a mailing list, if you
need insta-help use IRC.

-Mark

On Jan 20, 9:25 pm, Parris  wrote:
> come on... someone has to know the answer to this... are you all just
> using request action or something along those lines?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Query String

2009-01-21 Thread Cjo

Hi all,

I have to give access to my data from database using url.. For this i
have written a controller which in turn returns the data in XML
format. This part was actually easy. This url also contains query
string with which i have to get the data. Here is where i am stuck.

Let the three parameters coming as query string be LAB, FROMDATE and
TODATE. How can i know from the url that these 3 parameters are
present in the query string. All the 3 parameters must be there to
retrieve the data. So if there is any one missing I have to through an
error.

I have validated if the parameter is in the query string and its value
is empty.(http://localhost/spicesboard/labAnalysis/intimationList/?
Lab=&FromDate=2&ToDate=3)

I have to validate if the query string does not contain the parameter
itself. Ex(http://localhost/spicesboard/labAnalysis/intimationList/?
ToDate=3)



Regards
Sijo Jose C



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



Sending emails in console scripts

2009-01-21 Thread goncalo.marr...@gmail.com

Hi.

I'm writing a console shell that needs to send emails. I want to use
the EmailComponent but the only way i've managed to get it to work is
to manually create an instance of AppController an pass it to a
manually created instance of EmailComponent.

My code:

App::import('Core', 'Controller');
App::import('Controller', 'AppController');
$AppController = new AppController();
$AppController->constructClasses();

App::import('Component', 'Email');
$Email = new EmailComponent();
$Email->initialize($AppController);
$Email->startup($AppController);

Is there a simpler/more elegant way of achieving this? Shouldn't Shell
have a $components variable the same way it has a $uses variable?

Thanks in advance.

Gonçalo Marrafa
--~--~-~--~~~---~--~~
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: Form intermediate confirmation step in Modalbox

2009-01-21 Thread WebbedIT

Ordering of the parameters does not matter, the code I provided is
live from my app which is working fine.
--~--~-~--~~~---~--~~
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: baking cakephp on MAC OS

2009-01-21 Thread leo

> I  install fresh mysql, phpmyadmin but not working ?

phpMyadmin won't help much except to say a PHP is talking to a MySQL.

When you did the ps - ef | grep mysql.sock what were the outputs for
file= and socket= ? Was there more than one?

Do they correspond to the XAMPP directories?

What is the status of the servers as displayed by XAMPP?

Just a thought, but it may be that if you turn off web sharing (System
Preferences->Internet & Network->sharing->web sharing) that will sort
it all out as it should (I think) stop the native Apache server.

I used XAMPP on a PC sometime ago, but I used MAMP on my Mac and
second Chad's comments, except to say that I didn't like the setup
very much and eventually it killed itself, so I performed a base
install of MySQL. I also had the problem that when testing on Windows
on a different machine, Windows could only see the native Apache and
not the MAMP stack.

Now everything is stable and there is no confusion about which Apache
is which or which PHP etc. Unless you're very confident working in
UNIX, have OS X install disks, good backups and no hair, I wouldn't
recommend this route, though.


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



XML help

2009-01-21 Thread tjr88

HI,

I am looking use the XML to update and pass information from my
database. I have looked over the cake docs and googled abit but does
anyone know of any good reasources to point me in the right
direction??

Thanks
--~--~-~--~~~---~--~~
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: Callbacks not firing in JoinModel

2009-01-21 Thread Martin Westin


This is not a good day for writing...

Last paragraph should of-course read:
Where does this stuff get tested? I can't find any tests that use
callbacks on joining models in the core tests. Locating where they
test this would probably help a lot.




On Jan 21, 10:50 am, Martin Westin  wrote:
> Sorry, I guess meant saveAll() which came to mind when you mentioned
> __saveMulti().
> But at a quick glance, saveAll does not look like the answer.
>
> in __saveMulti I imagine that the problem is that when creating new
> links it looks like you end up at "$db->insertMulti..."(line 1334)
> which bypasses the model. But it also looks like I could try to
> reformat the array to a more "normal" data array for saves and have
> save called on the joining model... must try that later today.
>
> Where does this stuff get tested? I can't find any tests that use a
> "with" habtm in the core tests. Locating where they test this would
> probably help a lot.
>
> /Martin
>
> On Jan 21, 9:19 am, brian  wrote:
>
> > no! That method's private to Model. I meant, have a look through it
> > (and save) to see what's happening internally.
>
> > On Wed, Jan 21, 2009 at 2:41 AM, Martin Westin
>
> >  wrote:
>
> > > Thanks for the tip brian.
> > > Guess I'll have a go at switching from save to saveMulti and see what
> > > happens.
>
> > > /Martin
>
> > > On Jan 20, 8:20 pm, brian  wrote:
> > >> Have a look in Model::__saveMulti(). I still haven't quite figured out
> > >> the logic but the HABTM model's save() is called (which would trigger
> > >> its callbacks) in some instances. But it's still a bit foggy to
> > >> myself, as well. For instance, the block beginning at line 1286
> > >> starting with:
>
> > >> foreach ((array)$data as $row) {
>
> > >> ... doesn't make any sense to me at all. I can't understand how that
> > >> could work properly.
>
> > >> On Tue, Jan 20, 2009 at 5:02 AM, Martin Westin
>
> > >>  wrote:
>
> > >> > bump...
>
> > >> > My current working theory is that for some (to me) unknown reason
> > >> > (performance?) habtm relationships are created and deleted without
> > >> > fully utilizing the joining model. That is when you do:
>
> > >> > $data = array(
> > >> >  'A' => stuff for A,
> > >> >  'B' =>array('B'=>array(1,3,4))
> > >> > );
> > >> > $this->A->save($data);
>
> > >> > So I am thinking that I have to change the way I save these.
> > >> > Possibly I need to g as far as using $this->AB->delete() directly for
> > >> > unlinking.
>
> > >> > And, or-course, anyone who has been down this road before could be of
> > >> > great help by nudging me in the right direction.
>
> > >> > Non-essential background information:
> > >> > The reason I want to use the save and delete callbacks is that I want
> > >> > to put together a custom "counterCache" for a habtm relationship. That
> > >> > is why I want to trigger an update each time a "link" is created or
> > >> > deleted.
>
> > >> > /Martin
>
> > >> > On Jan 19, 8:56 am, Martin Westin  wrote:
> > >> >> Hi there,
>
> > >> >> I am trying to make use of a JoinModel for the first time but can't
> > >> >> get the hang of it. First I had some problems getting the class to
> > >> >> load at all but that is taken care of. Now I cant get all the
> > >> >> callbacks to fire.
>
> > >> >> I create associations between records of my two models expecting
> > >> >> beforeSave and afterSave to fire. But they don't.
>
> > >> >> I know the joining model is being used ($this->ModelA->ModelAsModelB
> > >> >> == instance of my expected class) and callbacks beforeFind and
> > >> >> afterFind are firing.
>
> > >> >> I found two old posts. One suggested using beforeSave (for whatever
> > >> >> purpose), suggesting to me that they should fire. The other suggested
> > >> >> using a callback on one of the "primary" models to call a custom
> > >> >> method on the joining model, suggesting that the callbacks should in
> > >> >> fact not fire.
>
> > >> >> Looking at the models used in the core tests I found no joining model
> > >> >> with any callback defined.
>
> > >> >> Does this mean that a joining model is really only "half a model"?
> > >> >> Since I haven't found anything to clearly state the opposite I have
> > >> >> expected these models to behave like any other once created. can
> > >> >> anyone clear the fog a little for me?
>
> > >> >> /Martin
--~--~-~--~~~---~--~~
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: Callbacks not firing in JoinModel

2009-01-21 Thread Martin Westin


Sorry, I guess meant saveAll() which came to mind when you mentioned
__saveMulti().
But at a quick glance, saveAll does not look like the answer.

in __saveMulti I imagine that the problem is that when creating new
links it looks like you end up at "$db->insertMulti..."(line 1334)
which bypasses the model. But it also looks like I could try to
reformat the array to a more "normal" data array for saves and have
save called on the joining model... must try that later today.

Where does this stuff get tested? I can't find any tests that use a
"with" habtm in the core tests. Locating where they test this would
probably help a lot.

/Martin




On Jan 21, 9:19 am, brian  wrote:
> no! That method's private to Model. I meant, have a look through it
> (and save) to see what's happening internally.
>
> On Wed, Jan 21, 2009 at 2:41 AM, Martin Westin
>
>  wrote:
>
> > Thanks for the tip brian.
> > Guess I'll have a go at switching from save to saveMulti and see what
> > happens.
>
> > /Martin
>
> > On Jan 20, 8:20 pm, brian  wrote:
> >> Have a look in Model::__saveMulti(). I still haven't quite figured out
> >> the logic but the HABTM model's save() is called (which would trigger
> >> its callbacks) in some instances. But it's still a bit foggy to
> >> myself, as well. For instance, the block beginning at line 1286
> >> starting with:
>
> >> foreach ((array)$data as $row) {
>
> >> ... doesn't make any sense to me at all. I can't understand how that
> >> could work properly.
>
> >> On Tue, Jan 20, 2009 at 5:02 AM, Martin Westin
>
> >>  wrote:
>
> >> > bump...
>
> >> > My current working theory is that for some (to me) unknown reason
> >> > (performance?) habtm relationships are created and deleted without
> >> > fully utilizing the joining model. That is when you do:
>
> >> > $data = array(
> >> >  'A' => stuff for A,
> >> >  'B' =>array('B'=>array(1,3,4))
> >> > );
> >> > $this->A->save($data);
>
> >> > So I am thinking that I have to change the way I save these.
> >> > Possibly I need to g as far as using $this->AB->delete() directly for
> >> > unlinking.
>
> >> > And, or-course, anyone who has been down this road before could be of
> >> > great help by nudging me in the right direction.
>
> >> > Non-essential background information:
> >> > The reason I want to use the save and delete callbacks is that I want
> >> > to put together a custom "counterCache" for a habtm relationship. That
> >> > is why I want to trigger an update each time a "link" is created or
> >> > deleted.
>
> >> > /Martin
>
> >> > On Jan 19, 8:56 am, Martin Westin  wrote:
> >> >> Hi there,
>
> >> >> I am trying to make use of a JoinModel for the first time but can't
> >> >> get the hang of it. First I had some problems getting the class to
> >> >> load at all but that is taken care of. Now I cant get all the
> >> >> callbacks to fire.
>
> >> >> I create associations between records of my two models expecting
> >> >> beforeSave and afterSave to fire. But they don't.
>
> >> >> I know the joining model is being used ($this->ModelA->ModelAsModelB
> >> >> == instance of my expected class) and callbacks beforeFind and
> >> >> afterFind are firing.
>
> >> >> I found two old posts. One suggested using beforeSave (for whatever
> >> >> purpose), suggesting to me that they should fire. The other suggested
> >> >> using a callback on one of the "primary" models to call a custom
> >> >> method on the joining model, suggesting that the callbacks should in
> >> >> fact not fire.
>
> >> >> Looking at the models used in the core tests I found no joining model
> >> >> with any callback defined.
>
> >> >> Does this mean that a joining model is really only "half a model"?
> >> >> Since I haven't found anything to clearly state the opposite I have
> >> >> expected these models to behave like any other once created. can
> >> >> anyone clear the fog a little for me?
>
> >> >> /Martin
--~--~-~--~~~---~--~~
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: RC3 file cache trouble

2009-01-21 Thread chanon

CakePHP 1.2 Final has been released and this is still a problem.

Basically you can't use FormHelper at all if the page has view caching
enabled.
Even if you put nocache around the element that the FormHelper resides
in and use requestAction to get the data for the element.
--~--~-~--~~~---~--~~
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: baking cakephp on MAC OS

2009-01-21 Thread Martin Westin


I can probably help if you can be a bit more specific about what is
not working? How far along are you?


On Jan 20, 9:23 pm, bookme  wrote:
> Thanks your suggestions...I tired all above solutions but not get
> success.
>
> I  install fresh mysql, phpmyadmin but not working ?
> still have same problem.
>
> please can somebody help me?
> Thanks
>
> On Jan 20, 2:45 pm, Martin Westin  wrote:
>
> > I second Mark's reply. If you simply call path/to/cake/console/cake
> > you will be using the system's version of php.
>
> > If you are committed to using a lot of shell stuff (such as bake), you
> > really should switch to using the system's php install. It will make
> > things easier in the long run. The setup is actually very easy. The
> > only real snag is the MySQL socket but I think that has been taken
> > care of in the latest builds of MySQL... but I may be wrong on that
> > one.
>
> > You need:
> > Install MySQL (from mysql.com).
> > Open /etc/apache2/httpd.conf and uncomment "LoadModule php5_module..."
> > around line 114. (and restart apache)
> > Drop your cake files into /Library/WebServer/Documents/ or /Users/
> > myname/Sites/
> > Do the trick for MySQL described in the post linked earlier
> > (Webweave's reply)
>
> > Optionally you can add production-style vhosts to serve several sites
> > and fake some nive domain names for each... then you will be in Cake
> > heaven. :)
>
> > There is a lot of info in the following bakery article. (But not all
> > of it is relevant 
> > still.)http://bakery.cakephp.org/articles/view/installing-cakephp-on-macos-x
>
> > /Martin
>
> > On Jan 20, 1:05 am, mark_story  wrote:
>
> > > Also since you are on macos check which php you are using.  I bet you
> > > are using the stock Apple PHP
>
> > > which php
>
> > > Should give you the path to the PHP that is the cli default.
>
> > > -Mark
>
> > > On Jan 19, 3:36 pm, leo  wrote:
>
> > > > If you're using XAMPP, I don't think it's a php/mysql config problem.
> > > > that is precisely  the problem these *AMP stacks are designed to
> > > > avoid. However, you might want to try the following. Incidentally,
> > > > that should be "Applications" PLURAL in your path.
>
> > > > Open a terminal, and type:
>
> > > >     ps -af | grep mysql.sock           [enter]
>
> > > > The result on my machine is:
>
> > > >     sh-3.2# ps -ef | grep mysql.sock
> > > >               74  2405  2379   0   0:15.88 ??         1:57.74 /usr/
> > > > local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/
> > > > mysql/data --user=mysql --pid-    file=/usr/local/mysql/data/
> > > > Leopard.local.pid --port=3306 --socket=/tmp/mysql.sock
> > > >     0  4814  4805   0   0:00.01 ttys000    0:00.01 grep mysql.sock
> > > > sh-3.2#
>
> > > > see the last bit? port=3306 socket=/tmp/mysql.sock
> > > > that path (/tmp/mysql.sock) is the path to MY socket (and the port is
> > > > the port!) yours will be different because mine is not an *AMP stack.
>
> > > > Now, in your htdocs directory create phpinfo.php with 
> > > > > as the sole content. Make sure there is no new line after the ?>
>
> > > > View the file in Safari and halfway down the first screen is the path
> > > > to the loaded configuration file. This is the one you need to edit to
> > > > configure php. Continue down the page - you'll need to scroll about
> > > > halfway down and see if there is a mysql section. If there is, I don't
> > > > think you have a problem with php.ini. If there isn't, mysql isn't
> > > > talking to PHP and you'll need to find and edit the appropriate part
> > > > of the ini file.
>
> > > > If I remember correctly, XAMPP already has a phpinfo link.
>
> > > > I don't pretend that this is a solution, but if you post the results
> > > > here, at least we'll have something to work with.
>
> > > > Good luck.
>
> > > > On Jan 19, 8:46 pm, bookme  wrote:
>
> > > > > Thanks for your solution...but still not working.
>
> > > > > I tried both above solution but not working.
>
> > > > > I am using xampp on MAC OS..
> > > > > ERROR :  Can't connect to local MySQL server through Socket '/var/
> > > > > mysql/mysql.sock ?
>
> > > > > I also set envornment variable using
> > > > > echo 'export PATH=Application/xampp/xamppfiles/htdocs/clalumni/cake/
> > > > > console/cake:$PATH' >> ~/.bash_profile
> > > > > echo 'export PATH=Application/xampp/xamppfiles/lib/php:$PATH' >>
> > > > > ~/.bash_profile
>
> > > > > but still not able to run cake bake?
>
> > > > > Please help me to run cake bake on MAC OS.
> > > > > Thanks
>
> > > > > On Jan 19, 8:22 pm, leo  wrote:
>
> > > > > > I used to use MAMP. It used a non-standard port for the DB. Check
> > > > > > which port you're using and add it as shown in the database.php
> > > > > > comments:
>
> > > > > >  * host =>
> > > > > >  * the host you connect to the database.  To add a socket or port
> > > > > > number, use 'port' => #
> > > > > >  *
--~--~-~--~~~---~--~~
You received this message because you are s

Re: Callbacks not firing in JoinModel

2009-01-21 Thread brian

no! That method's private to Model. I meant, have a look through it
(and save) to see what's happening internally.


On Wed, Jan 21, 2009 at 2:41 AM, Martin Westin
 wrote:
>
> Thanks for the tip brian.
> Guess I'll have a go at switching from save to saveMulti and see what
> happens.
>
> /Martin
>
>
> On Jan 20, 8:20 pm, brian  wrote:
>> Have a look in Model::__saveMulti(). I still haven't quite figured out
>> the logic but the HABTM model's save() is called (which would trigger
>> its callbacks) in some instances. But it's still a bit foggy to
>> myself, as well. For instance, the block beginning at line 1286
>> starting with:
>>
>> foreach ((array)$data as $row) {
>>
>> ... doesn't make any sense to me at all. I can't understand how that
>> could work properly.
>>
>> On Tue, Jan 20, 2009 at 5:02 AM, Martin Westin
>>
>>  wrote:
>>
>> > bump...
>>
>> > My current working theory is that for some (to me) unknown reason
>> > (performance?) habtm relationships are created and deleted without
>> > fully utilizing the joining model. That is when you do:
>>
>> > $data = array(
>> >  'A' => stuff for A,
>> >  'B' =>array('B'=>array(1,3,4))
>> > );
>> > $this->A->save($data);
>>
>> > So I am thinking that I have to change the way I save these.
>> > Possibly I need to g as far as using $this->AB->delete() directly for
>> > unlinking.
>>
>> > And, or-course, anyone who has been down this road before could be of
>> > great help by nudging me in the right direction.
>>
>> > Non-essential background information:
>> > The reason I want to use the save and delete callbacks is that I want
>> > to put together a custom "counterCache" for a habtm relationship. That
>> > is why I want to trigger an update each time a "link" is created or
>> > deleted.
>>
>> > /Martin
>>
>> > On Jan 19, 8:56 am, Martin Westin  wrote:
>> >> Hi there,
>>
>> >> I am trying to make use of a JoinModel for the first time but can't
>> >> get the hang of it. First I had some problems getting the class to
>> >> load at all but that is taken care of. Now I cant get all the
>> >> callbacks to fire.
>>
>> >> I create associations between records of my two models expecting
>> >> beforeSave and afterSave to fire. But they don't.
>>
>> >> I know the joining model is being used ($this->ModelA->ModelAsModelB
>> >> == instance of my expected class) and callbacks beforeFind and
>> >> afterFind are firing.
>>
>> >> I found two old posts. One suggested using beforeSave (for whatever
>> >> purpose), suggesting to me that they should fire. The other suggested
>> >> using a callback on one of the "primary" models to call a custom
>> >> method on the joining model, suggesting that the callbacks should in
>> >> fact not fire.
>>
>> >> Looking at the models used in the core tests I found no joining model
>> >> with any callback defined.
>>
>> >> Does this mean that a joining model is really only "half a model"?
>> >> Since I haven't found anything to clearly state the opposite I have
>> >> expected these models to behave like any other once created. can
>> >> anyone clear the fog a little for me?
>>
>> >> /Martin
> >
>

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