Re: pagination - related model/custom sql

2007-10-18 Thread Adwin Wijaya

I think (base on the source code), You can use paginate() function in
1.2 with array.
so do the query first with custom sql query, then pass the result into
controller pagination methods.

i think it will work ;)

adwin


On Oct 19, 4:55 am, austint01 <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am using pagination in 1.2.
> is it possible to filter my results by looking at records in related
> models using pagination?
>
> $filters = array("
> lower(Applicant.fname) like '%".low($search)."%'
> OR lower(Applicant.personal) like '%".low($search)."%'
>
> OR lower(Education.schoolname) like '%".low($search)."%'
> ");
>
> but Education.schoolname creates an SQL error as the SQL query is only
> looking at Applicant e.g. SELECT FROM `applicants` WHERE... etc.
>
> is it possible to filter my results using related models using
> pagination?
>
> thanks


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



Re: pretty-print (indent) view output

2007-10-18 Thread Wayne Fay

If you file a bug, perhaps someone in the Cake Dev team will implement
it. But this seems to be a low priority enhancement to me.

What you're basically proposing is somehow in-lining htmltidy (or
similar) into the HTTP response, so that all HTML output from Cake is
formatted nicely before it is sent to the user's web browser. I can
see this perhaps being useful in development, but wouldn't want it
turned on in a production environment.

Thinking about it some more, I recall that there is an Apache module for this --
http://mod-tidy.sourceforge.net/

Wayne

On 10/18/07, Rex <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I see that in cakephp a view output is not properly indented. This
> makes it very difficult to debug a problem.
> I suggest that all cakephp (HTML) output should be indented properly
> so that when we try to view-source using mozilla, we get a
> beatutifully formatted code which all humans can see and understand
> clearly.
>
> regards,
> Rex
>
>
> >
>

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



Re: pretty-print (indent) view output

2007-10-18 Thread Felix Geisendörfer
You heard of Firebug?

-- Felix
Rex wrote:
> Hi,
>
> I see that in cakephp a view output is not properly indented. This
> makes it very difficult to debug a problem.
> I suggest that all cakephp (HTML) output should be indented properly
> so that when we try to view-source using mozilla, we get a
> beatutifully formatted code which all humans can see and understand
> clearly.
>
> regards,
> Rex
>
>
> >
>
>   

-- 
--
My Blog: http://www.thinkingphp.org
My Business: http://www.fg-webdesign.de

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



pretty-print (indent) view output

2007-10-18 Thread Rex

Hi,

I see that in cakephp a view output is not properly indented. This
makes it very difficult to debug a problem.
I suggest that all cakephp (HTML) output should be indented properly
so that when we try to view-source using mozilla, we get a
beatutifully formatted code which all humans can see and understand
clearly.

regards,
Rex


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



Re: How to save model without auto_increment?

2007-10-18 Thread Grant Cox

Cake needs the table to have a primary key, but this does not need to
be a auto-incrementing integer.

I have a model here for configuration, where the primary key is a
varchar.  All the model has is

class AppConfig extends AppModel
{
var $name = 'AppConfig';
var $primaryKey = 'title';
var $useTable = 'configuration';
}

and this works fine using the title primary key (INSERT / UPDATE as
appropriate).  This is using Cake 1.2.x, almost the latest trunk
(update every week or so).


On Oct 18, 11:53 pm, majna <[EMAIL PROTECTED]> wrote:
> How to save model with Model->save() when Primary key is not
> auto_increment?
> Model->create() and $this->Model->id=null wont work here.
>
> Example:
> Table Statuses
>
> PK code
> text
> description
>
> Statuses : primaryKey = 'code':
>
> Model->save() always do UPDATE ?!
> Becouse there is in Add view input Model/code.


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



Re: Where do non-Cake PHP files go in structure?

2007-10-18 Thread Grant Cox

Yes, in the webroot (or subfolder thereof).  There is nothing special
needed to call it - just the direct URL.  Cake's .htaccess files only
redirect a query through cake if the direct file doesn't exist.

I haven't had problems outputting excel files from a cake action
though, so it can be done.  Just make sure you have
Configure::write('debug', 0)
to stop any cake debug logs, or php notices etc from messing up the
file format.  And the usual headers of course.  Oh, and if you are
rendering a view to generate the excel file, make sure your layout
isn't getting in the way.



On Oct 19, 4:42 am, "Wayne Fay" <[EMAIL PROTECTED]> wrote:
> On my dev servers, I am able to export to Excel with no troubles. In
> the production server, it just comes out as text directly in the web
> browser. So there seems to be something weird with that environment,
> and I assume the headers are not being written out properly.
>
> So, I built a little plain jane export.php script that establishes its
> own mysql connection and uses sql and echo to write the file out to
> Excel. And it works just fine.
>
> Where should I put this file in the /cake/app directory? In webroot?
> And is there a special way/url I should use to call/access it?
>
> Wayne


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



Re: Ajax request from an external web site to a controller action in a cakephp web site

2007-10-18 Thread Joaquín Windmüller

You cannot do ajax requests to pages outside the domain where the
script was server.

Security reasons. You need a proxy script in your server to do the
request. Google that.

On Oct 15, 12:11 pm, Cruentatio <[EMAIL PROTECTED]> wrote:
> Hi, I need to write a little JS file in which I need to make a call
> like this http_request.open('GET', url, true); where URL is a cakephp-
> like url (http://my-site.com/controller/action/par1/par2) and return a
> view in the web site that start the request and put in a dedicated
> DIV.
>
> The JS should be added to any web-site.
>
> Can you help me!?
>
> Thanks!!!
> Bye!


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



pagination - related model/custom sql

2007-10-18 Thread austint01

Hi,

I am using pagination in 1.2.
is it possible to filter my results by looking at records in related
models using pagination?

$filters = array("
lower(Applicant.fname) like '%".low($search)."%'
OR lower(Applicant.personal) like '%".low($search)."%'

OR lower(Education.schoolname) like '%".low($search)."%'
");

but Education.schoolname creates an SQL error as the SQL query is only
looking at Applicant e.g. SELECT FROM `applicants` WHERE... etc.

is it possible to filter my results using related models using
pagination?

thanks


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



Re: How do you stop $ajax->remoteTimer

2007-10-18 Thread francky06l

I came across this, there is noway to do it, except reload the
complete page (as HTML).
Actually I did hack a bit the prototype class in order to do. I mean I
did copy and tweak the prototype in my own js file.

On Oct 18, 7:03 pm, thun <[EMAIL PROTECTED]> wrote:
> How do you stop or kill $ajax->remoteTimer once it has been started?


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



Re: problem in validation due to loop in view file

2007-10-18 Thread francky06l

To me there is a misunderstanding on the syntax of submit ... I do not
think (unless I am very behind 1.2), that the first parameter uses a
"model.field" syntax, it's more likely to be the name of the submit
button..
Now I do not know what you are trying to achieve ..


On Oct 18, 8:18 pm, "manuj bansal" <[EMAIL PROTECTED]> wrote:
> i am working in cakephp1.2
>
> my view code is like this
>
> $i=0;
> foreach($rows as row)
> {
> $i++
> echo 
> $form->submit('Modelname.name'.$i,array('labe'=>'labelname','error'=>'length
> should be less than 20 characters'));
>
> }
>
> in my model code validation is like this
>
> var $validate = array(*'name*' => array('error' => array('maxLength', 20)));
>
> now problem comes in name it should be like 'name'.$i
>
> but it gives error to 'foreach loop' when running in model
>
> i want to use this inbuilt function
>
> plz help me to sort out this issue THANKS IN ADVANCE


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



Re: Form manipulation

2007-10-18 Thread 2000Man

Maybe I was too quick with that conclusion. Actually somehow only the
loginform works properly, but I'm still looking for the difference
between that form en the others (except from the different models)...
Anyone else is having problems with the Security component?

On 18 okt, 16:58, 2000Man <[EMAIL PROTECTED]> wrote:
> Hi larry,
>
> I should have don't that before starting my topic here, because the
> Security-component has been greatly improved! Sorry for bothering
> you..


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



Where do non-Cake PHP files go in structure?

2007-10-18 Thread Wayne Fay

On my dev servers, I am able to export to Excel with no troubles. In
the production server, it just comes out as text directly in the web
browser. So there seems to be something weird with that environment,
and I assume the headers are not being written out properly.

So, I built a little plain jane export.php script that establishes its
own mysql connection and uses sql and echo to write the file out to
Excel. And it works just fine.

Where should I put this file in the /cake/app directory? In webroot?
And is there a special way/url I should use to call/access it?

Wayne

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



problem in validation due to loop in view file

2007-10-18 Thread manuj bansal
i am working in cakephp1.2

my view code is like this

$i=0;
foreach($rows as row)
{
$i++
echo 
$form->submit('Modelname.name'.$i,array('labe'=>'labelname','error'=>'length
should be less than 20 characters'));
}

in my model code validation is like this

var $validate = array(*'name*' => array('error' => array('maxLength', 20)));

now problem comes in name it should be like 'name'.$i

but it gives error to 'foreach loop' when running in model

i want to use this inbuilt function

plz help me to sort out this issue THANKS IN ADVANCE

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



Re: Output of RSS contains spaces

2007-10-18 Thread Wayne Fay

Which helper? I probably have the same one in my controller, unless
its a custom-built one. And if its not custom, then a bug needs to be
filed so it can be fixed.

Wayne

On 10/18/07, Charlie van de Kerkhof <[EMAIL PROTECTED]> wrote:
>
> Found it. Was in a helper that I included but not used. :(
> Thnx anyway...
>
> On Oct 18, 6:56 pm, "Wayne Fay" <[EMAIL PROTECTED]> wrote:
> > I am getting a single space at the beginning of my CSV file.
> > Fortunately for me, the space is not a problem. And in my case, all
> > the code is being echo'ed from my Controller method directly, so there
> > are no .thtml or .ctp files in my app that are being called.
> >
> > So I assume this space is coming from somewhere deep inside Cake (??).
> > But I don't know where (yet). I'm using 1.2.0.5427. I haven't tried
> > with any later builds of 1.2.
> >
> > Wayne
> >
> > On 10/18/07, Charlie van de Kerkhof <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > > Hi,
> > > I'm trying to get the RSS functionality working in CakePHP 1.2 Working
> > > just fine, but it gives me 1 space before the opening header  > > So the RSS is not recognized as such.
> > > I opened every ctp file that is used by this action but none of them
> > > conatins spaces before or after the PHP tags.
> > > Even the models and controllers used by this action!
> >
> > > I'm stuck. anyone had the same experience and found a solution?
> >
> > > thnx!
> > > - Charlie
>
>
> >
>

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



Re: Output of RSS contains spaces

2007-10-18 Thread Charlie van de Kerkhof

Found it. Was in a helper that I included but not used. :(
Thnx anyway...

On Oct 18, 6:56 pm, "Wayne Fay" <[EMAIL PROTECTED]> wrote:
> I am getting a single space at the beginning of my CSV file.
> Fortunately for me, the space is not a problem. And in my case, all
> the code is being echo'ed from my Controller method directly, so there
> are no .thtml or .ctp files in my app that are being called.
>
> So I assume this space is coming from somewhere deep inside Cake (??).
> But I don't know where (yet). I'm using 1.2.0.5427. I haven't tried
> with any later builds of 1.2.
>
> Wayne
>
> On 10/18/07, Charlie van de Kerkhof <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi,
> > I'm trying to get the RSS functionality working in CakePHP 1.2 Working
> > just fine, but it gives me 1 space before the opening header  > So the RSS is not recognized as such.
> > I opened every ctp file that is used by this action but none of them
> > conatins spaces before or after the PHP tags.
> > Even the models and controllers used by this action!
>
> > I'm stuck. anyone had the same experience and found a solution?
>
> > thnx!
> > - Charlie


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



How do you stop $ajax->remoteTimer

2007-10-18 Thread thun

How do you stop or kill $ajax->remoteTimer once it has been started?


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



Re: Output of RSS contains spaces

2007-10-18 Thread Wayne Fay

I am getting a single space at the beginning of my CSV file.
Fortunately for me, the space is not a problem. And in my case, all
the code is being echo'ed from my Controller method directly, so there
are no .thtml or .ctp files in my app that are being called.

So I assume this space is coming from somewhere deep inside Cake (??).
But I don't know where (yet). I'm using 1.2.0.5427. I haven't tried
with any later builds of 1.2.

Wayne

On 10/18/07, Charlie van de Kerkhof <[EMAIL PROTECTED]> wrote:
>
> Hi,
> I'm trying to get the RSS functionality working in CakePHP 1.2 Working
> just fine, but it gives me 1 space before the opening header  So the RSS is not recognized as such.
> I opened every ctp file that is used by this action but none of them
> conatins spaces before or after the PHP tags.
> Even the models and controllers used by this action!
>
> I'm stuck. anyone had the same experience and found a solution?
>
> thnx!
> - Charlie
>
>
> >
>

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



Re: File upload handling in cakephp 1.2

2007-10-18 Thread Rex

Hi Sam,

This worked. Thanks for the great help.

regards,
Rex


On Oct 18, 9:05 pm, "Samuel DeVore" <[EMAIL PROTECTED]> wrote:
> $form->create('User',   array('action'  =>  'upload', 'type=>'file'));
>
> this should make your form mime/multipart which is needed for upload
>
> Sam D
> On 10/18/07, Rex <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > Hi,
>
> > I am trying to handle a file upload in cakephp 1.2
> > Problem is that the uploaded file information is not available in the
> > controller.
> > In the controller, $this->params['form'] is empty.
> > Please help me debug this.
>
> > TIA,
> > Rex
>
> > //==View
> >  > echo$form->create('User',   array('action'  =>  'upload'));
> > echo$form->label('Users.fileUpload','Upload UserDatabase
> > File',null);
> > echo$form->file('File');
> > echo$form->submit('Upload');
> > echo$form->end();
> > ?>
>
> > //==Controller  
> >  > class   UsersController extends AppController
> > {
> > var $name   = 'Users';
> > var $helpers = array('Html', 'Form');
>
> > function upload()
> > {
> > var_dump($this->params['form']); print  '';
>
> > }
> > ?>
>
> --
> (the old fart) the advice is free, the lack of crankiness will cost you
>
> - its a fine line between a real question and an idiot
>
> http://blog.samdevore.com/archives/2007/03/05/when-open-source-bugs-me/


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



Output of RSS contains spaces

2007-10-18 Thread Charlie van de Kerkhof

Hi,
I'm trying to get the RSS functionality working in CakePHP 1.2 Working
just fine, but it gives me 1 space before the opening header http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: File upload handling in cakephp 1.2

2007-10-18 Thread Samuel DeVore

$form->create('User',   array('action'  =>  'upload', 'type=>'file'));

this should make your form mime/multipart which is needed for upload

Sam D
On 10/18/07, Rex <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I am trying to handle a file upload in cakephp 1.2
> Problem is that the uploaded file information is not available in the
> controller.
> In the controller, $this->params['form'] is empty.
> Please help me debug this.
>
> TIA,
> Rex
>
> //==View
>  echo$form->create('User',   array('action'  =>  'upload'));
> echo$form->label('Users.fileUpload','Upload UserDatabase
> File',null);
> echo$form->file('File');
> echo$form->submit('Upload');
> echo$form->end();
> ?>
>
> //==Controller  
>  class   UsersController extends AppController
> {
> var $name   = 'Users';
> var $helpers = array('Html', 'Form');
>
> function upload()
> {
> var_dump($this->params['form']); print  '';
>
> }
> ?>
>
>
> >
>


-- 
(the old fart) the advice is free, the lack of crankiness will cost you

- its a fine line between a real question and an idiot

http://blog.samdevore.com/archives/2007/03/05/when-open-source-bugs-me/

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



Re: How to use different arrayconditions on the same field.

2007-10-18 Thread grigri

Assuming you don't just want to do this:

$this->Article->findAll(array('Article.publishdate' => "BETWEEN
'2007-01-01 15:00' AND '2007-08-08 15:00'"));

You can do this:

$this->Article->findAll(array(
array('Article.publishdate' => '2007-01-01 15:00'),
array('Article.publishdate' => '2007-08-08 15:00')
));

If you've got a lot of conditions it might be good to build them up
first:

$conditions = array();
$conditions[] = array('Article.publishdate' => '> 2007-01-01 15:00');
$conditions[] = array('Article.publishdate' => '< 2007-08-08 15:00');
$conditions = array(
  'or' => array(
array('Article.always_find_this_one' => 1),
$conditions
  )
);

$this->Article->findAll($conditions);

On Oct 18, 12:58 pm, gafuser <[EMAIL PROTECTED]> wrote:
> Hi,
> Are there a way to use the same field multiple times in
> arrayconditions?
> The problem is that you have to use the same arraykey again which of
> course is impossible.
>
> An example is when I want to get all articles between two given dates
> like this.
>
> $this->Article->findAll(array(
> 'Article.publishdate' => '> 2007-01-01 15:00',
> 'Article.publishdate' => '< 2007-08-08 15:00'
> ));
>
> The second condition will overwrite the first. A dirty hack to make it
> work is insert af space after one of the arraykeys. Like this:
> $this->Article->findAll(array(
> 'Article.publishdate' => '> 2007-01-01 15:00',
> 'Article.publishdate ' => '< 2007-08-08 15:00'
> ));
>
> But that is really ugly and there is no way(that I know of) to make
> the formhelper do it.
>
> Thanks.


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



File upload handling in cakephp 1.2

2007-10-18 Thread Rex

Hi,

I am trying to handle a file upload in cakephp 1.2
Problem is that the uploaded file information is not available in the
controller.
In the controller, $this->params['form'] is empty.
Please help me debug this.

TIA,
Rex

//==View
create('User',   array('action'  =>  'upload'));
echo$form->label('Users.fileUpload','Upload UserDatabase
File',null);
echo$form->file('File');
echo$form->submit('Upload');
echo$form->end();
?>

//==Controller  
params['form']); print  '';

}
?>


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



[1.2] Problem with bake

2007-10-18 Thread Jakobloekke

Hi guys,
I'm new to cakephp, and I'm stuck with a problem using the bake
script:

I can bake a DB configuration without problems.
When I try to bake a model, my terminal prints out some sql-errors,
but I can create a new model manually.

When I try to bake a controller I get the following error, and:
Fatal error: ConnectionManager::getDataSource - Non-existent data
source default in /Library/WebServer/cake1.2.x.x/cake/libs/model/
connection_manager.php on line 111
Then the bake script terminates.

Can anyone tell me where I went wrong?

thanks,
Jakob


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



Re: How to set up read-only viewing in normal routing and scaffolded viewing in admin routing?

2007-10-18 Thread Olaf Greve

Hi,

Thanks for your answer!
Also: I've CC'ed you directly on this message too, as yesterday my replies
to the list were rejected for some reason. I hope you don't mind...:P

> Also in 1.2 (you need it for the Auth component) you can put
> var $scaffold = 'admin';
>
> in your controller, to use scaffold only for admin_ actions, then make
> the others views like always.

Aha!
That sounds excellent!
I had decided not to go for version 1.2 due to its Alpha status, but this
makes it definitely worth a try!

> Anyway, my advice is to bake everything (using the console bake
> script ) and start building on that base rather than stick to the
> scaffold.

Hmmm, time is a major limiting factor for this particular assignment
(basically, I'll only have next Monday, Tuesday and at best a small part of
Wednesday for implementing the back-office and all sorts of intricate logic
on top of it - outside of those ours I'd have to work on it in my spare
time, which, having a baby would mean having to 'find the 25th hour in the
day'), so the main question would be how easily/quickly the method you
propose could be realised. In this case, the main advantage of having an
admin routed scaffold mechanism, would be that I'd have virtually no
overhead for building neat admin views (in this case 95% of the focus of the
assignment is on the front end, and not on the back-office)...
I hope this console script is easy to fit those needs and restrictions then?

Cheers!
Olaf



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



Re: Combining Conditions in query's with findAll()

2007-10-18 Thread Amit Badkas
On 10/18/07, BoSc <[EMAIL PROTECTED]> wrote:
>
>
> Hi,
>
>
> I've got 3 tables with a 1:n relationship:
>
> - author (has many books)
> ^
> |
> |
> V
> - books (belongs to categories) (has many authors)


- I think you made a mistake here, actual relationships may be author HABTM
books and books HABTM authors

|
> |
> V
>
> - categories (has many books)
>
>
> What I would like to do on one page, is show a categorized view of all
> books by a specific author. The problem lies in the fact that each
> category and each book also has some kind of sorting involved, which
> states at what place in a category a book should be shown...
>
> >From which Point of View should I query this, and am I able to
> implement this in 1 query?
>
> What I would like to end up with is the following array
>
> array
>category 2
>   book 1
>  name
>  blabla
>   book 3
>  name
>  blabla
>   book 2
>  name
>  blabla
>category 1
>   book 4
>  name
>  blabla
>   book 6
>  name
>  blabla
>   book 5
>  name
>  blabla
>
> The problem is, when I use findAll on Category, I'm not able to choose
> how Cake should order the Books. Any workarounds?


- Use Category->findAll(null, null, 'Category.name ASC'); and in category
model, define hasMany relation with book like, $hasMany = array('Book' =>
array('order' => 'Book.name ASC'));

-- 
Regards,
Amit

http://amitrb.wordpress.com/
http://cheesecake-photoblog.org/
http://www.sanisoft.com/blog/author/amitbadkas

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



How to use different arrayconditions on the same field.

2007-10-18 Thread gafuser

Hi,
Are there a way to use the same field multiple times in
arrayconditions?
The problem is that you have to use the same arraykey again which of
course is impossible.

An example is when I want to get all articles between two given dates
like this.

$this->Article->findAll(array(
'Article.publishdate' => '> 2007-01-01 15:00',
'Article.publishdate' => '< 2007-08-08 15:00'
));

The second condition will overwrite the first. A dirty hack to make it
work is insert af space after one of the arraykeys. Like this:
$this->Article->findAll(array(
'Article.publishdate' => '> 2007-01-01 15:00',
'Article.publishdate ' => '< 2007-08-08 15:00'
));

But that is really ugly and there is no way(that I know of) to make
the formhelper do it.

Thanks.


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



Re: Ajax request from an external web site to a controller action in a cakephp web site

2007-10-18 Thread maschoen

The Cake View returned could be an HTML snippet that is inserted with
the innerHTML() method.


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



Re: Simple authentication for directory??

2007-10-18 Thread maschoen

Instead of  replace SRC with
"get_picture.php/1".   get_picture.php checks whether the user is
logged in and if so uses the following PHP code to return the picture.

$fileno = $_SERVER['QUERY_STRING'];
$filename = "/picture/directory/not-below-webroot/PICTURE" . $fileno .
".jpg";
$image = imagecreatefromjpeg($filename);
if ($image == null)
{
return;
}
header("content-type: image/jpeg");
imagejpeg($image);
imagedestroy($image);

This requires that PHP be configured with the gd library.   I'm not
sure if that is common or not.


On Oct 17, 7:23 am, Jacob83 <[EMAIL PROTECTED]> wrote:
> Nobody knows about a solution for this problem?
> I think it's a very common question, isn't it?
>
> On 6 Okt., 07:58, Jacob83 <[EMAIL PROTECTED]> wrote:
>
> > Hi out there,
> > is there any way to limit access to a directory to logged in users
> > only? i.e. i don't want everybody to be able to see my pictures/
> > documents by simply entering the url.
> > I think I'll have to use a php file which flushes the file ... (bad
> > performance??)
> > but perhaps someone has already written something like this...
> > Regards,
> > Jacob


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



How to use different arrayconditions on the same field.

2007-10-18 Thread gafuser

Hi,
Are there a way to use the same field multiple times in
arrayconditions?
The problem is that you have to use the same arraykey again which of
course is impossible.

An example is when I want to get all articles between two given dates
like this.

$this->Article->findAll(array(
'Article.publishdate' => '> 2007-01-01 15:00',
'Article.publishdate' => '< 2007-08-08 15:00'
));

The second condition will overwrite the first. A dirty hack to make it
work, is insert af space after one of the arraykeys. Like this:
$this->Article->findAll(array(
'Article.publishdate' => '> 2007-01-01 15:00',
'Article.publishdate ' => '< 2007-08-08 15:00'
));

But that is really ugly and there is no way(that I know of) to make
the formhelper do it.

Thanks in advance,
Niels


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



Re: Pagination & RSS > Warning (1.1)

2007-10-18 Thread Lian3W

Take a look at you pagination.php file, this error normally occurs
when you have a line return (a.k.a crlf) after the PHP close tag "?>"
because of the copy-paste operation. Check that file, erase everything
(blank spaces and line returns) after the end of the PHP block.

Hope it helps...

Regards,
Emiliano

On Oct 18, 5:21 am, bigbass <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I included the pagination component (http://bakery.cakephp.org/
> articles/view/pagination) in my articles, but now I get a warning
> when debug = 2:
> "Cannot modify header information - headers already sent by (output
> started at /path/to/myapp/views/helpers/pagination.php:556)"
>
> Should I be troubled?
>
> Bassy regards,
> Benjamin


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



Re: CakePHP 1.2 - Form select

2007-10-18 Thread silid

I could do with finding a good tutorial too.

I found the samples at http://www.donutczar.com/cake1point2/donuts/form_helper

They are a good start.

On Oct 14, 4:49 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Its okay now. I just add 1 null value to the attribute of select
>
> before it was...
> echo $form->select("gender", array("" => "- Select One -", "M" =>
> "Male", "F" => "Female"), null, false);
>
> after..
> echo $form->select("gender", array("" => "- Select One -", "M" =>
> "Male", "F" => "Female"), null, null, false);
>
> Can't seem to find a good tutorial for CakePHP 1.2, do you have any
> recommendation?
>
> thanks,
>
> Wendell


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



Re: Form manipulation

2007-10-18 Thread 2000Man

Hi larry,

I should have don't that before starting my topic here, because the
Security-component has been greatly improved! Sorry for bothering
you..


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



Re: Pagination & RSS > Warning (1.1)

2007-10-18 Thread FallenJehova


This happens because you can't send any sort of header to a browser if
you've already sent any output.

Take a look at pagination.php line 556 to see what might be echoing
any output. If it's the end of the file, check that you have not left
some spaces at the end of it.



On Oct 18, 5:21 am, bigbass <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I included the pagination component (http://bakery.cakephp.org/
> articles/view/pagination) in my articles, but now I get a warning
> when debug = 2:
> "Cannot modify header information - headers already sent by (output
> started at /path/to/myapp/views/helpers/pagination.php:556)"
>
> Should I be troubled?
>
> Bassy regards,
> Benjamin


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



How to save model without auto_increment?

2007-10-18 Thread majna

How to save model with Model->save() when Primary key is not
auto_increment?
Model->create() and $this->Model->id=null wont work here.

Example:
Table Statuses

PK code
text
description

Statuses : primaryKey = 'code':

Model->save() always do UPDATE ?!
Becouse there is in Add view input Model/code.


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



Re: Combining Conditions in query's with findAll()

2007-10-18 Thread grigri

It's real code - try it! So is Category->findAllById(). Cakey
automagic goodness!

They're nice shortcuts, but they do make it difficult to set other
options, like order, recursive, and whatnot.

On Oct 18, 11:06 am, BoSc <[EMAIL PROTECTED]> wrote:
> Btw is the findAllByAuthorId intented to be pseudo-code, or is
> this really possible in CakePHP?
>
> On Oct 18, 11:55 am, grigri <[EMAIL PROTECTED]> wrote:
>
> > I'm not 100% sure of the "official" way of doing this, but I'd do it
> > by putting a specialized search function in the model. Which model is
> > up to you - a bit of a grey area. I've written a quick (untested!)
> > example, in which I've put it in the Author class. Depending on other
> > stuff, it might make more sense for you to have a
> > "findAllCategorizedByAuthor" function in the Book model, or something.
> > Anyway:
>
> > class Author extends AppModel {
> >   var $name = "Author";
>
> >   var $hasMany = array(
> > 'Book'
> >   );
>
> >   function findCategorizedBooks($author_id) {
> > // First get all the books
> > // Order them by whatever you like, add extra conditions, ...
> > // Set recursive to -1 - we'll get the categories later
> > $books = $this->Book->findAllByAuthorId($author_id);
>
> > // Build a lookup table of category ids to book indices
> > $catLUT = array();
> > foreach ($books as $bookIdx => $book) {
> >   $catId = $book['Book']['category_id'];
> >   if (!isset($catLUT[$catId])) {
> > $catLUT[$catId] = array();
> >   }
>
> >   array_push($catLUT[$catId], $bookIdx);
> > }
> > // Grab the IDs for the findAll
> > $catIds = array_keys($catLUT);
>
> > // Find all the relevant categories
> > // Again, set recursive to -1 because we've already for the books
> > and the author
> > // Order by whatever you like, add extra conditions, bla bla woof
> > woof
> > $cats = $this->Book->Category->findAllById($catIds);
>
> > // Now loop through the category list and append the books
> > foreach ($cats as $catIdx => $cat) {
> >   $cats[$catIdx]['Book'] = array();
> >   foreach ($catLUT[$cat['Category']['id']] as $bookIdx) {
> > array_push($cats[$catIdx]['Book'], $books[$bookIdx]['Book']);
> >   }
> > }
>
> > // We're done
> > return $cats;
> >   }
>
> > }
>
> > Like I said, not tested, but I have written similar code before on a
> > cake project of mine - the concept is sound.
> > (Formatted a bit better here:http://openpaste.org/en/3506/)
>
> > On Oct 18, 10:06 am, BoSc <[EMAIL PROTECTED]> wrote:
>
> > > Hi,
>
> > > I've got 3 tables with a 1:n relationship:
>
> > > - author (has many books)
> > > ^
> > > |
> > > |
> > > V
> > > - books (belongs to categories) (has many authors)
>
> > >  |
> > >  |
> > > V
>
> > > - categories (has many books)
>
> > > What I would like to do on one page, is show a categorized view of all
> > > books by a specific author. The problem lies in the fact that each
> > > category and each book also has some kind of sorting involved, which
> > > states at what place in a category a book should be shown...
>
> > > >From which Point of View should I query this, and am I able to
>
> > > implement this in 1 query?
>
> > > What I would like to end up with is the following array
>
> > > array
> > >category 2
> > >   book 1
> > >  name
> > >  blabla
> > >   book 3
> > >  name
> > >  blabla
> > >   book 2
> > >  name
> > >  blabla
> > >category 1
> > >   book 4
> > >  name
> > >  blabla
> > >   book 6
> > >  name
> > >  blabla
> > >   book 5
> > >  name
> > >  blabla
>
> > > The problem is, when I use findAll on Category, I'm not able to choose
> > > how Cake should order the Books. Any workarounds?
>
> > > Thanks


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



Re: this->read with sorting

2007-10-18 Thread grigri

Sorting the primary result on read doesn't make any sense, because
read uses the primary key to find ONE record, which will always be
unique.

So presumably you mean sorting the secondary finds (associations),
like your 'Followup'. Well, the easiest way is to set the 'orderBy'
attribute in your association directly:

class Note extends AppModel {
  var $hasMany = array(
'Followup' => array(
  'className' => 'Followup',
  'orderBy' => 'Followup.created DESC'
)
  );
}

Now when you do a find/findAll on Note with recursive 1 or more [note:
read() just calls find() internally -- which in turn calls findAll()],
your associated Followup results will be sorted however you like.

If you need to perform a one-off find will a different sort order,
just change the association data:

(assuming you're in a controller)
// Store old order by
$oldOrderBy = $this->Note->hasMany['Followup']['orderBy'];
// Change it
$this->Note->hasMany['Followup']['orderBy'] = "Followup.created ASC";
// Read
$foo = $this->Note->read(null, $id);
// Change it back
$this->Note->hasMany['Followup']['orderBy'] = $oldOrderBy;

On Oct 18, 8:53 am, jwerd <[EMAIL PROTECTED]> wrote:
> Is there anyway to do sorting with simply using this->read?
>
> $this->set('note', $this->Note->read(null, $id));
>
> or do I have to change it to something else like findAll?
>
> Also I use recursive = 2 and I actually want an association called
> Followup sorted by it's created column.  Everything works fine as it
> is, I'm just wondering whether I can pass some argument before I do
> the this->read to sort the Followup.created column?
>
> Please let me know if you need more understanding of this.  It's late
> here :P


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



Re: Combining Conditions in query's with findAll()

2007-10-18 Thread BoSc

Btw is the findAllByAuthorId intented to be pseudo-code, or is
this really possible in CakePHP?

On Oct 18, 11:55 am, grigri <[EMAIL PROTECTED]> wrote:
> I'm not 100% sure of the "official" way of doing this, but I'd do it
> by putting a specialized search function in the model. Which model is
> up to you - a bit of a grey area. I've written a quick (untested!)
> example, in which I've put it in the Author class. Depending on other
> stuff, it might make more sense for you to have a
> "findAllCategorizedByAuthor" function in the Book model, or something.
> Anyway:
>
> class Author extends AppModel {
>   var $name = "Author";
>
>   var $hasMany = array(
> 'Book'
>   );
>
>   function findCategorizedBooks($author_id) {
> // First get all the books
> // Order them by whatever you like, add extra conditions, ...
> // Set recursive to -1 - we'll get the categories later
> $books = $this->Book->findAllByAuthorId($author_id);
>
> // Build a lookup table of category ids to book indices
> $catLUT = array();
> foreach ($books as $bookIdx => $book) {
>   $catId = $book['Book']['category_id'];
>   if (!isset($catLUT[$catId])) {
> $catLUT[$catId] = array();
>   }
>
>   array_push($catLUT[$catId], $bookIdx);
> }
> // Grab the IDs for the findAll
> $catIds = array_keys($catLUT);
>
> // Find all the relevant categories
> // Again, set recursive to -1 because we've already for the books
> and the author
> // Order by whatever you like, add extra conditions, bla bla woof
> woof
> $cats = $this->Book->Category->findAllById($catIds);
>
> // Now loop through the category list and append the books
> foreach ($cats as $catIdx => $cat) {
>   $cats[$catIdx]['Book'] = array();
>   foreach ($catLUT[$cat['Category']['id']] as $bookIdx) {
> array_push($cats[$catIdx]['Book'], $books[$bookIdx]['Book']);
>   }
> }
>
> // We're done
> return $cats;
>   }
>
> }
>
> Like I said, not tested, but I have written similar code before on a
> cake project of mine - the concept is sound.
> (Formatted a bit better here:http://openpaste.org/en/3506/)
>
> On Oct 18, 10:06 am, BoSc <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I've got 3 tables with a 1:n relationship:
>
> > - author (has many books)
> > ^
> > |
> > |
> > V
> > - books (belongs to categories) (has many authors)
>
> >  |
> >  |
> > V
>
> > - categories (has many books)
>
> > What I would like to do on one page, is show a categorized view of all
> > books by a specific author. The problem lies in the fact that each
> > category and each book also has some kind of sorting involved, which
> > states at what place in a category a book should be shown...
>
> > >From which Point of View should I query this, and am I able to
>
> > implement this in 1 query?
>
> > What I would like to end up with is the following array
>
> > array
> >category 2
> >   book 1
> >  name
> >  blabla
> >   book 3
> >  name
> >  blabla
> >   book 2
> >  name
> >  blabla
> >category 1
> >   book 4
> >  name
> >  blabla
> >   book 6
> >  name
> >  blabla
> >   book 5
> >  name
> >  blabla
>
> > The problem is, when I use findAll on Category, I'm not able to choose
> > how Cake should order the Books. Any workarounds?
>
> > Thanks


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



Re: Combining Conditions in query's with findAll()

2007-10-18 Thread BoSc

Hi Grigri,

Thanks for all your trouble, it's more clear to me now!

I'll go and try to implement this in my app.

(it's clear to me now that this is not something that is done in 1
Cakephp function/method)

On Oct 18, 11:55 am, grigri <[EMAIL PROTECTED]> wrote:
> I'm not 100% sure of the "official" way of doing this, but I'd do it
> by putting a specialized search function in the model. Which model is
> up to you - a bit of a grey area. I've written a quick (untested!)
> example, in which I've put it in the Author class. Depending on other
> stuff, it might make more sense for you to have a
> "findAllCategorizedByAuthor" function in the Book model, or something.
> Anyway:
>
> class Author extends AppModel {
>   var $name = "Author";
>
>   var $hasMany = array(
> 'Book'
>   );
>
>   function findCategorizedBooks($author_id) {
> // First get all the books
> // Order them by whatever you like, add extra conditions, ...
> // Set recursive to -1 - we'll get the categories later
> $books = $this->Book->findAllByAuthorId($author_id);
>
> // Build a lookup table of category ids to book indices
> $catLUT = array();
> foreach ($books as $bookIdx => $book) {
>   $catId = $book['Book']['category_id'];
>   if (!isset($catLUT[$catId])) {
> $catLUT[$catId] = array();
>   }
>
>   array_push($catLUT[$catId], $bookIdx);
> }
> // Grab the IDs for the findAll
> $catIds = array_keys($catLUT);
>
> // Find all the relevant categories
> // Again, set recursive to -1 because we've already for the books
> and the author
> // Order by whatever you like, add extra conditions, bla bla woof
> woof
> $cats = $this->Book->Category->findAllById($catIds);
>
> // Now loop through the category list and append the books
> foreach ($cats as $catIdx => $cat) {
>   $cats[$catIdx]['Book'] = array();
>   foreach ($catLUT[$cat['Category']['id']] as $bookIdx) {
> array_push($cats[$catIdx]['Book'], $books[$bookIdx]['Book']);
>   }
> }
>
> // We're done
> return $cats;
>   }
>
> }
>
> Like I said, not tested, but I have written similar code before on a
> cake project of mine - the concept is sound.
> (Formatted a bit better here:http://openpaste.org/en/3506/)
>
> On Oct 18, 10:06 am, BoSc <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I've got 3 tables with a 1:n relationship:
>
> > - author (has many books)
> > ^
> > |
> > |
> > V
> > - books (belongs to categories) (has many authors)
>
> >  |
> >  |
> > V
>
> > - categories (has many books)
>
> > What I would like to do on one page, is show a categorized view of all
> > books by a specific author. The problem lies in the fact that each
> > category and each book also has some kind of sorting involved, which
> > states at what place in a category a book should be shown...
>
> > >From which Point of View should I query this, and am I able to
>
> > implement this in 1 query?
>
> > What I would like to end up with is the following array
>
> > array
> >category 2
> >   book 1
> >  name
> >  blabla
> >   book 3
> >  name
> >  blabla
> >   book 2
> >  name
> >  blabla
> >category 1
> >   book 4
> >  name
> >  blabla
> >   book 6
> >  name
> >  blabla
> >   book 5
> >  name
> >  blabla
>
> > The problem is, when I use findAll on Category, I'm not able to choose
> > how Cake should order the Books. Any workarounds?
>
> > Thanks


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



Re: Combining Conditions in query's with findAll()

2007-10-18 Thread grigri

I'm not 100% sure of the "official" way of doing this, but I'd do it
by putting a specialized search function in the model. Which model is
up to you - a bit of a grey area. I've written a quick (untested!)
example, in which I've put it in the Author class. Depending on other
stuff, it might make more sense for you to have a
"findAllCategorizedByAuthor" function in the Book model, or something.
Anyway:

class Author extends AppModel {
  var $name = "Author";

  var $hasMany = array(
'Book'
  );

  function findCategorizedBooks($author_id) {
// First get all the books
// Order them by whatever you like, add extra conditions, ...
// Set recursive to -1 - we'll get the categories later
$books = $this->Book->findAllByAuthorId($author_id);

// Build a lookup table of category ids to book indices
$catLUT = array();
foreach ($books as $bookIdx => $book) {
  $catId = $book['Book']['category_id'];
  if (!isset($catLUT[$catId])) {
$catLUT[$catId] = array();
  }

  array_push($catLUT[$catId], $bookIdx);
}
// Grab the IDs for the findAll
$catIds = array_keys($catLUT);

// Find all the relevant categories
// Again, set recursive to -1 because we've already for the books
and the author
// Order by whatever you like, add extra conditions, bla bla woof
woof
$cats = $this->Book->Category->findAllById($catIds);

// Now loop through the category list and append the books
foreach ($cats as $catIdx => $cat) {
  $cats[$catIdx]['Book'] = array();
  foreach ($catLUT[$cat['Category']['id']] as $bookIdx) {
array_push($cats[$catIdx]['Book'], $books[$bookIdx]['Book']);
  }
}

// We're done
return $cats;
  }
}

Like I said, not tested, but I have written similar code before on a
cake project of mine - the concept is sound.
(Formatted a bit better here: http://openpaste.org/en/3506/ )

On Oct 18, 10:06 am, BoSc <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I've got 3 tables with a 1:n relationship:
>
> - author (has many books)
> ^
> |
> |
> V
> - books (belongs to categories) (has many authors)
>
>  |
>  |
> V
>
> - categories (has many books)
>
> What I would like to do on one page, is show a categorized view of all
> books by a specific author. The problem lies in the fact that each
> category and each book also has some kind of sorting involved, which
> states at what place in a category a book should be shown...
>
> >From which Point of View should I query this, and am I able to
>
> implement this in 1 query?
>
> What I would like to end up with is the following array
>
> array
>category 2
>   book 1
>  name
>  blabla
>   book 3
>  name
>  blabla
>   book 2
>  name
>  blabla
>category 1
>   book 4
>  name
>  blabla
>   book 6
>  name
>  blabla
>   book 5
>  name
>  blabla
>
> The problem is, when I use findAll on Category, I'm not able to choose
> how Cake should order the Books. Any workarounds?
>
> Thanks


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



Re: How to run a background process in CakePhp

2007-10-18 Thread wluigi

yes you can do this ;

create an additional action : "backgroundscript" that call your exec
("/usr/bin/php yourscript.php" >/dev/null &");

in your main real action use curl to call your "backgroundscript"
action with the appropriates options : curl_setopt($ch,CURLOPT_TIMEOUT,
1) curl_setopt($ch,CURLOPT_NOBODY,true)
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true) ...

this will wait just 1 second.

All this isn't pretty at all but it works fine

> On Oct 18, 1:41 am, McFadly <[EMAIL PROTECTED]> wrote:
> Also if you're using cakephp 1.2 look into the console.  cakebaker has
> a good starting 
> point:http://cakebaker.42dh.com/2007/05/07/writing-a-custom-cakephp-console...
>
> On Oct 17, 1:50 pm, fr3nch13 <[EMAIL PROTECTED]> wrote:
>
> > hint - search this group for 'cron jobs'
>
> > On Oct 17, 1:58 pm, Felix Geisendörfer <[EMAIL PROTECTED]> wrote:
>
> > > You might want to check out this extension if you you need things like 
> > > this:
>
> > >http://www.vl-srm.net/doc/
>
> > > However, you find it easier to have a queue table that is processed by a
> > > cron executed script for your background processing needs.
>
> > > -- Felix
> > > --
> > > My Blog:http://www.thinkingphp.org
> > > My Business:http://www.fg-webdesign.de
>
> > > Baz wrote:
> > > > This isn't a very CakePHP question.
>
> > > > It's straight PHP. The short answer is no. Anything you execute in PHP
> > > > is going to be done in a blocking call.
> > > > --
> > > > Baz L
> > > > Web Development 2.0
> > > >http://WebDevelopment2.com/
>
> > > > On 10/17/07, *regent* <[EMAIL PROTECTED] >
> > > > wrote:
>
> > > > I need to run a php script in the background.  I have figured out I
> > > > can run it like this:
>
> > > > exec ("/usr/bin/php yourscript.php" >/dev/null &");
>
> > > > I have 2 questions concerning this:
>
> > > > 1) Can I run a php script within the CakePhp framework?  I've been
> > > > able to run it outside the framework, I just put the script under
> > > > webroot.  But can i run it within the framework so I can take
> > > > advantage of CakePhp's extra functionality?  To be more clear, I 
> > > > want
> > > > the script to reside in one of my views folders, so I can still take
> > > > advantage of Cake's functions.
>
> > > > 2) How do I pass arguments to the script?  I need the exact syntax.
> > > > I've searched google and could not find a clear example of how to do
> > > > this.
>
> > > > Thanks.


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



Re: Dynamic form fields / multi-dimension array inside $this->data

2007-10-18 Thread francky06l

I found a "syntax" in order to do this with form helper in cake 1.2

$form->input('Request/group][1][test'
will give data['Request']['group'][1]['test']

$form->input('Request/group][1][3][test'
will give data['Request']['group'][1][3]['test']

$form->input('Request/group][1][3][5][test'
will give data['Request']['group'][1][3][5]['test']

hope this helps

On Oct 17, 6:47 pm, daphonz <[EMAIL PROTECTED]> wrote:
> Sure.
>
> The following example uses Cake 1.2's FormHelper, but the general
> syntax should work for 1.1's HTMLHelper:
> for ($i=0;$i<$weekMax;$i++) {
>  echo $form->text('User.start]['.$i);
>
> }
>
> Or you could just generate the inputs by hand, using the structure:
>  value="" />
>  value="" />
> etc.
>
> Using either of the above methods, the $this->data array in your
> controller will have $this->data['start'] as an array with the same
> number of elements you specified in your view.  You could then
> serialize this array before storing it in your DB to reduce the number
> of fields you need.
>
> Hope this helps,
>
> Casey
>
> On Oct 16, 12:20 pm, MarsDev <[EMAIL PROTECTED]> wrote:
>
> > Hi guys,
>
> > I am building a training scheduling app where I am stuck at the weekly
> > schedule list form. Each training class is a multi-week schedule,
> > somewhere between 15-20 weeks. I have a table that keep tracks thes
> > length of the training class. However, when it comes to the frontend
> > rendering, I don't know how to assign the text fields to capture all
> > the start date / end date of the each week:
>
> > For example:
> > 
> > Week 1
> > 
> > input('User/start_date', array('size' =>
> > '20')?>
> > tagErrorMsg('User/start_date', 'Start Date
> > is required'); ?>
>
> > 
>
> > 
> > input('User/end_date', 
> > array('size' => '20')?>
> > > $html->tagErrorMsg('User/end_date', 'End Date is required'); ?>
>
> > 
> > 
> > ...
> > ...
>
> > Is there some way to make cakePHP keep all week schedule data into
> > $this->data['User']['start'][0] to $this->data['User']['start'][15],
> > for instance? If so, what should I put for the first parameter of
> > HtmlHelper::input() method?
>
> > Thanks a lot!!


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



Combining Conditions in query's with findAll()

2007-10-18 Thread BoSc

Hi,


I've got 3 tables with a 1:n relationship:

- author (has many books)
^
|
|
V
- books (belongs to categories) (has many authors)

 |
 |
V

- categories (has many books)


What I would like to do on one page, is show a categorized view of all
books by a specific author. The problem lies in the fact that each
category and each book also has some kind of sorting involved, which
states at what place in a category a book should be shown...

>From which Point of View should I query this, and am I able to
implement this in 1 query?

What I would like to end up with is the following array

array
   category 2
  book 1
 name
 blabla
  book 3
 name
 blabla
  book 2
 name
 blabla
   category 1
  book 4
 name
 blabla
  book 6
 name
 blabla
  book 5
 name
 blabla

The problem is, when I use findAll on Category, I'm not able to choose
how Cake should order the Books. Any workarounds?

Thanks


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



Pagination & RSS > Warning (1.1)

2007-10-18 Thread bigbass

Hi,

I included the pagination component (http://bakery.cakephp.org/
articles/view/pagination) in my articles, but now I get a warning
when debug = 2:
"Cannot modify header information - headers already sent by (output
started at /path/to/myapp/views/helpers/pagination.php:556)"

Should I be troubled?

Bassy regards,
Benjamin


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



this->read with sorting

2007-10-18 Thread jwerd

Is there anyway to do sorting with simply using this->read?

$this->set('note', $this->Note->read(null, $id));

or do I have to change it to something else like findAll?

Also I use recursive = 2 and I actually want an association called
Followup sorted by it's created column.  Everything works fine as it
is, I'm just wondering whether I can pass some argument before I do
the this->read to sort the Followup.created column?

Please let me know if you need more understanding of this.  It's late
here :P


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



Re: Recommendation: which security auth plugin/component/helper should I use

2007-10-18 Thread ihti

othAuth component or AuthComponent in CakePHP 1.2

On Oct 18, 3:50 am, Kristopher <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I just wanted some feedback as to which auth plugin/component/helper I
> should use for administrative logins via SSL (over https).
>
> What are some of the options and what have you used that works.  I am
> using CakePHP 1.2.
>
> Some of what I found in the Bakery:
>
>  -othAuth component
>  -obAuth Simple Authentication
>  -dAuth
>  -RBAuth
>  -YACCA
>
> Anybody have pros or cons for any of these or suggestions for others.
>
> I'm not looking for something too complicated but here's a list of
> what I would be interested in:
>  -https authentication (SSL) with sessions
>  -user management (view/add/edit/delete)
>  -group acl management (role based - view/add/edit/delete)
>
> Nothing too fancy. Pretty much the basics.
>
> Thanks.


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