Saving Date and Time NOT in the Model/Database (cleanUpFields not working)

2007-12-04 Thread Baz
OK,

I've banged my head against the wall a million times. This is my problem:

I got date and time fields which I need. They are not associated with the
model or database.

I call them like so:

echo $form->input('from', array('label' => 'From', 'type' => 'date',
'div' => 'date'));
echo $form->input('to', array('label' => 'To', 'type' => 'date',
'div' => 'date'));
echo $form->input('time', array('label' => 'Time', 'type' => 'time',
'div' => 'date'));


However, cleanUpFields doesn't work it's magic like if those fields were in
the database.

Any ideas?
Is there a way to force the model to consider those fields as its own?

Ideas would be greatly appreciated.
--
Baz L
Web Development 2.0: Web Design, CakePHP, Javascript
http://www.WebDevelopment2.com/

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



Looking for german freelancers or even better a company

2007-12-04 Thread burzum

Hello, ive posted this already in the german group but i dont think
that all german developers read this group, so ive decided to post
this here again.

I have a project that i want to give away because of the size and the
law-traps for me as a single person and my small business.

The client refused already to work with us companies and wants a
german company or freelancer. So please go on reading my posting in
the german cakephp group:

http://groups.google.com/group/cakephp-de/browse_thread/thread/b5e7c06ba171714b
--~--~-~--~~~---~--~~
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: limit of 200 items in new array???

2007-12-04 Thread Adam Royle

Sounds strange that there would be such a limit. Do some debugging (in
bootstrap and your controller) to figure out where things start to go
astray.

Adam

On Dec 5, 3:48 pm, phalvrson <[EMAIL PROTECTED]> wrote:
> This is probably mostly a PHP question, but I will ask it here in case
> there is some hidden CakePHP interaction that I am not aware of.
>
> I have a model called Product and I have a view where I list all of
> the products.  Each product has a quantity that I want to be update-
> able from the list - but all at once, so there is only one submit
> button and then I process all quantity updates at once.
>
> I build a new array for the update, updProdQty[], using the product ID
> as the key, and the current quantity as the value, and process that
> array to update the quantity values... (All of this in a form input
> statement)   It works great - but only for the first 200 entries...
>
> The really bizarre thing is that I have 207 products in the db and
> they get listed correctly.  But for some reason my array that I build
> for update has only 200 entries!!!  but I create an entry in the array
> for each item that I print in the list.  Is there any limitation to
> the number of items in an array if you are creating the array with
> input elements?  Or can anyone think of any other reasons I only get
> 200 entries?
>
> Here is the view code:
>
>   
>
>   
>   
>   Product Name
>   Quantity
>   Delete
>   
>for($i = 0; $i < count($products); $i++) {
> print("\n");
> echo 
> $html->link(htmlspecialchars_decode($products[$i]['Product']
> ['name'], ENT_QUOTES), "/products/view/".$products[$i]['Product']
> ['id']);
> print("\n");
> $this_qty = $products[$i]['Product']['quantity'];
> $this_pid = $products[$i]['Product']['id'];
> printf(" size=
> \"5\" value=\"%d\" ", $this_qty);
> if ($this_qty < 0) {
> print("class=\"negativeQtyBox\" />\n");
> } else {
> print("class=\"qtyBox\" />\n");
> }
> print("\n \"deleteMe[$this_pid]\" />");
> print("\n");
> }
> print("\n");
> echo $html->submit('Update');
>   ?>
>   
>
> And here is the controller code:
>
> function index()
> {
> $this->pageTitle = 'Inventory';
> if (empty($this->params['form'])) {
> $this->set('products', $this->Product->findAll(null, 
> null, 'name
> ASC'));
> } else {
> foreach ($this->params['form']['updProdQty'] as $pid 
> => $qty) {
> $this->Product->updQty($pid, $qty);
> }
> if (isset($this->params['form']['deleteMe'])) {
> foreach ($this->params['form']['deleteMe'] as 
> $pid => $qty) {
> $this->Product->del($pid);
> }
> }
> $this->set('products', $this->Product->findAll(null, 
> null, 'name
> ASC'));
> }
> }
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



limit of 200 items in new array???

2007-12-04 Thread phalvrson

This is probably mostly a PHP question, but I will ask it here in case
there is some hidden CakePHP interaction that I am not aware of.

I have a model called Product and I have a view where I list all of
the products.  Each product has a quantity that I want to be update-
able from the list - but all at once, so there is only one submit
button and then I process all quantity updates at once.

I build a new array for the update, updProdQty[], using the product ID
as the key, and the current quantity as the value, and process that
array to update the quantity values... (All of this in a form input
statement)   It works great - but only for the first 200 entries...

The really bizarre thing is that I have 207 products in the db and
they get listed correctly.  But for some reason my array that I build
for update has only 200 entries!!!  but I create an entry in the array
for each item that I print in the list.  Is there any limitation to
the number of items in an array if you are creating the array with
input elements?  Or can anyone think of any other reasons I only get
200 entries?

Here is the view code:

  
  
  
  Product Name
  Quantity
  Delete
  
  \n");
echo 
$html->link(htmlspecialchars_decode($products[$i]['Product']
['name'], ENT_QUOTES), "/products/view/".$products[$i]['Product']
['id']);
print("\n");
$this_qty = $products[$i]['Product']['quantity'];
$this_pid = $products[$i]['Product']['id'];
printf("\n");
} else {
print("class=\"qtyBox\" />\n");
}
print("\n");
print("\n");
}
print("\n");
echo $html->submit('Update');
  ?>
  

And here is the controller code:

function index()
{
$this->pageTitle = 'Inventory';
if (empty($this->params['form'])) {
$this->set('products', $this->Product->findAll(null, 
null, 'name
ASC'));
} else {
foreach ($this->params['form']['updProdQty'] as $pid => 
$qty) {
$this->Product->updQty($pid, $qty);
}
if (isset($this->params['form']['deleteMe'])) {
foreach ($this->params['form']['deleteMe'] as 
$pid => $qty) {
$this->Product->del($pid);
}
}
$this->set('products', $this->Product->findAll(null, 
null, 'name
ASC'));
}
}


--~--~-~--~~~---~--~~
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: Function to ignore an element of an array

2007-12-04 Thread Adam Royle

One more thing, if you're not going to use a regular expression to
split a string, you should just use:

$input_usernames = explode(",", $data['Mail']['receiver_username']);

Cheers,
Adam

On Dec 5, 3:38 pm, Adam Royle <[EMAIL PROTECTED]> wrote:
> I would use a single query and some array functions. This is off the
> cuff (untested) but should work as far as I can tell. Might do it
> slightly differently if you need the id of the User as well to do
> further processing, but you should be able to figure out the rest
> yourself.
>
> $input_usernames = split(",", $data['Mail']['receiver_username']);
> $found_usernames = $this->User->findAll( array('User.username' =>
> $input_usernames), 'User.field' );
> $found_usernames = Set::extract($found_usernames,
> '{n}.User.username');
>
> $orphan_usernames = array_diff($input_usernames, $found_usernames);
> pr($orphan_usernames); // the list of usernames that were not found
>
> Cheers,
> Adam
>
> On Dec 5, 1:15 pm, butangphp <[EMAIL PROTECTED]> wrote:
>
> > Basically, I am writing a mailing class
>
> > $comma = ",";
> > if (strchr($data['Mail']['receiver_username'], $comma))
> > {
> > //remove the commas and create and array of usernames
> > $email_list = split(",", 
> > $data['Mail']['receiver_username']);
>
> > foreach ($email_list as $receivers)
> > {
> > $receivers_id = 
> > $this->User->getUserIdByUsername($receivers);
> > $conditions = 'User.id = "'.$receivers_id.'"';
> > $receivers = $this->User->field('username', 
> > $conditions);
>
> > if ($receivers == 'FALSE')
> > {
> > //if one of the usernames is false, remove it and 
> > continue with the
> > rest
> > }
>
> > }
>
> > If theres a comma (and hence more than one name listed) I split the
> > string and create an array.
> > I need a function in order to weed out usernames that are not in the
> > database.  Any suggestions??
--~--~-~--~~~---~--~~
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: Function to ignore an element of an array

2007-12-04 Thread Adam Royle

I would use a single query and some array functions. This is off the
cuff (untested) but should work as far as I can tell. Might do it
slightly differently if you need the id of the User as well to do
further processing, but you should be able to figure out the rest
yourself.

$input_usernames = split(",", $data['Mail']['receiver_username']);
$found_usernames = $this->User->findAll( array('User.username' =>
$input_usernames), 'User.field' );
$found_usernames = Set::extract($found_usernames,
'{n}.User.username');

$orphan_usernames = array_diff($input_usernames, $found_usernames);
pr($orphan_usernames); // the list of usernames that were not found

Cheers,
Adam

On Dec 5, 1:15 pm, butangphp <[EMAIL PROTECTED]> wrote:
> Basically, I am writing a mailing class
>
> $comma = ",";
> if (strchr($data['Mail']['receiver_username'], $comma))
> {
> //remove the commas and create and array of usernames
> $email_list = split(",", $data['Mail']['receiver_username']);
>
> foreach ($email_list as $receivers)
> {
> $receivers_id = 
> $this->User->getUserIdByUsername($receivers);
> $conditions = 'User.id = "'.$receivers_id.'"';
> $receivers = $this->User->field('username', 
> $conditions);
>
> if ($receivers == 'FALSE')
> {
> //if one of the usernames is false, remove it and 
> continue with the
> rest
> }
>
> }
>
> If theres a comma (and hence more than one name listed) I split the
> string and create an array.
> I need a function in order to weed out usernames that are not in the
> database.  Any suggestions??
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Function to ignore an element of an array

2007-12-04 Thread butangphp

Basically, I am writing a mailing class

$comma = ",";
if (strchr($data['Mail']['receiver_username'], $comma))
{
//remove the commas and create and array of usernames
$email_list = split(",", $data['Mail']['receiver_username']);

foreach ($email_list as $receivers)
{
$receivers_id = 
$this->User->getUserIdByUsername($receivers);
$conditions = 'User.id = "'.$receivers_id.'"';
$receivers = $this->User->field('username', 
$conditions);

if ($receivers == 'FALSE')
{
//if one of the usernames is false, remove it and 
continue with the
rest
}
}

If theres a comma (and hence more than one name listed) I split the
string and create an array.
I need a function in order to weed out usernames that are not in the
database.  Any suggestions??

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



CLOB in cakephp 1.2

2007-12-04 Thread sanderken

Hello everybody.

After a long quest on the internet and through the cakephp API, I
can't find a solution to my problem .

Here goes:
Cakephp is working great with my oracle database. Now I want to store
messages > 4000 chars (VARCHAR2). So I want to go with a CLOB.

When I fill the data straight in the database with some 20k
characters , all happens as wanted: model reads the CLOB and prints
it. No problem.

Now the REAL problem: I can't get the data BACK into the database !

This is the error: Warning (2): ociexecute() [function.ociexecute]:
ORA-01704: string literal too long [CORE/cake/libs/model/datasources/
dbo/dbo_oracle.php, line 291]

Help would be greatly appreciated !

--~--~-~--~~~---~--~~
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: Do you hardcode your menu links?

2007-12-04 Thread Adam Royle

Similar to Dragonl, I store my menu links in an array (almost exactly
the same structure incidentally) and have developed a helper to write
out css menus, which also highlights the current page.

At the moment I've kept the array hardcoded in my element because it
doesn't change often, but it could easily be generated from a
controller dynamically.

Cheers,
Adam

On Dec 5, 9:09 am, DragonI <[EMAIL PROTECTED]> wrote:
> I store menu and submenu links in a config file as an array which is
> loaded and cached in beforeRender in app_controller. I have my own
> menu helper which displays the menu in an element
>
> $config['mainMenu'] = array(
> 1 => array(
> 'title' => 'Home',
> 'url' => '/',
> 'desc' => 'Home',
> ),
> 2 => array(
> 'title' => 'Search',
> 'url' => '/search/',
> 'desc' => 'Search',
> ), etc
>
> On Dec 4, 4:52 pm, kristofer <[EMAIL PROTECTED]> wrote:
>
> > I usually pull in an element to handle dynamic navigation.
>
> > On Dec 4, 4:46 pm, Arne-Kolja Bachstein <[EMAIL PROTECTED]> wrote:
>
> > > Hi there,
>
> > > I've got a quite generic question... do you usually hardcode your menu
> > > links [in your views] when developing something with cake, or do you
> > > implement something like link management models or something? What's
> > > the usual way here in your opinion?
>
> > > Greetings
>
> > > Arne
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



counterQuery or fields not working in hasMany association (getting DISTINCT results) for 1.2?

2007-12-04 Thread Jon Hinson

Does counterQuery not work in 1.2? Instead of it doing COUNT(*), I
want it to do COUNT(DISTINCT User.id). Also, in my hasMany
association, I was trying to put fields in the 'fields' key, and it
wasn't working. I tried just one field (User.id), and it was still
returning all fields.

Also, is there any simple way to add a DISTINCT to the query? Or a
GROUP BY? That would be great.

Thanks,
Jon
--~--~-~--~~~---~--~~
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: i18n: static language references with __("My lang key", true) in models and controllers

2007-12-04 Thread cakeFreak

Well sorry, this works in controllers.

I had problems using it in a validation rule inside models.
--~--~-~--~~~---~--~~
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: Do you hardcode your menu links?

2007-12-04 Thread DragonI

I store menu and submenu links in a config file as an array which is
loaded and cached in beforeRender in app_controller. I have my own
menu helper which displays the menu in an element

$config['mainMenu'] = array(
1 => array(
'title' => 'Home',
'url' => '/',
'desc' => 'Home',
),
2 => array(
'title' => 'Search',
'url' => '/search/',
'desc' => 'Search',
), etc


On Dec 4, 4:52 pm, kristofer <[EMAIL PROTECTED]> wrote:
> I usually pull in an element to handle dynamic navigation.
>
> On Dec 4, 4:46 pm, Arne-Kolja Bachstein <[EMAIL PROTECTED]> wrote:
>
> > Hi there,
>
> > I've got a quite generic question... do you usually hardcode your menu
> > links [in your views] when developing something with cake, or do you
> > implement something like link management models or something? What's
> > the usual way here in your opinion?
>
> > Greetings
>
> > Arne
--~--~-~--~~~---~--~~
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: Do you hardcode your menu links?

2007-12-04 Thread kristofer

I usually pull in an element to handle dynamic navigation.

On Dec 4, 4:46 pm, Arne-Kolja Bachstein <[EMAIL PROTECTED]> wrote:
> Hi there,
>
> I've got a quite generic question... do you usually hardcode your menu
> links [in your views] when developing something with cake, or do you
> implement something like link management models or something? What's
> the usual way here in your opinion?
>
> Greetings
>
> Arne

--~--~-~--~~~---~--~~
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: Stop Users From Going Back After Logout

2007-12-04 Thread Grant Cox

What kiger was getting at is that the user can only see what is in
their browser's cache - which is what they were allowed to see a
second ago anyway...  They won't be able to click any links, or
perform any actions.

But regardless, what you really want is browser history management.
Search google for javascript to destroy the browser history, or have
some javascript that on page load performs an ajax request to check
login status - this javascript will run again even on hitting the back
button.

But without Javascript I don't think it is possible - unless anyone
knows of page headers that can instruct a browser not to cache at
all?  I haven't heard of such a thing.


On Dec 5, 4:39 am, Joyce <[EMAIL PROTECTED]> wrote:
> I see. Hopefully I can get what you mean by that.
>
> I will give it a shot. Thanks.
>
> On Dec 5, 2:31 am, "Chris Hartjes" <[EMAIL PROTECTED]> wrote:
>
> > On Dec 4, 2007 1:26 PM, Joyce <[EMAIL PROTECTED]> wrote:
>
> > > Thanks Chris,
>
> > > I will look through your tutorials. I am using CakePHP 1.1, can that
> > > work?
>
> > The Auth component is not available in 1.2, but I believe you can use
> > the Security component to do similar things.
>
> > --
> > Chris Hartjes
>
> > My motto for 2007:  "Just build it, damnit!"
>
> > @TheKeyboard -http://www.littlehart.net/atthekeyboard
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Do you hardcode your menu links?

2007-12-04 Thread Arne-Kolja Bachstein

Hi there,

I've got a quite generic question... do you usually hardcode your menu
links [in your views] when developing something with cake, or do you
implement something like link management models or something? What's
the usual way here in your opinion?

Greetings

Arne
--~--~-~--~~~---~--~~
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: Creating and persisting objects independent of the controller

2007-12-04 Thread francky06l

If you object as got a save method, this should work .. Now if you
expect Cake to save it . directly no.. \
Maybe just what is this object, what you want to save, how (file,
memory ...) where ? ...

On Dec 4, 9:53 pm, Deane <[EMAIL PROTECTED]> wrote:
> If I want to create an object, set some properties, and save it, can I
> do this in my controller:
>
> $MyObject = new ThingaMajig();
> $MyObject->some_property = "some value";
> $MyObject->save()
>
> This object has nothing to do with my controller.  This just needs to
> happen in one of the methods.
>
> We've tried this, and Cake seems to ignore it.  It runs through the
> code (code on either side of it runs), but this code does not result
> in any SQL or any database record.
--~--~-~--~~~---~--~~
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: Creating and persisting objects independent of the controller

2007-12-04 Thread Chris Hartjes

On Dec 4, 2007 3:53 PM, Deane <[EMAIL PROTECTED]> wrote:
> We've tried this, and Cake seems to ignore it.  It runs through the
> code (code on either side of it runs), but this code does not result
> in any SQL or any database record.

Forgive my ignorance, but what do you mean by 'Cake seems to ignore it'?

-- 
Chris Hartjes

My motto for 2007:  "Just build it, damnit!"

@TheKeyboard - http://www.littlehart.net/atthekeyboard

--~--~-~--~~~---~--~~
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: bake newbie problem with configuration

2007-12-04 Thread Phil

directories are
/webroot/cake/app
/webroot/cake/cake/console
user phil
from dir /webroot/cake/app
calling
../cake/console/cake bake
user PATH  /usr/local/bin:/usr/bin:/bin:/usr/games

1.2.0.5875 pre-beta

the response is
../cake/console/
Hello Phil
Fatal Error: cannot redeclare class Class ClassRegistry etc

On 2 Dec, 18:29, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote:
> How are you calling it?
> Are you using 1.2 prebeta, svn trunk/branch ?
> What is your path?
>
> I've used it on debian and ubuntu, never had problems.
>
> 2007/12/2, Phil <[EMAIL PROTECTED]>:
>
>
>
> > Hi
> > I have a simple cakephp app working, now trying to use bake
> > downloaded 1.2
> > installed php cli
>
> > error message is
> > cannot redeclare class ClassRegistry in /webroot/cake/cake/libs
> > class_registry.php on line 39
>
> > I am using debian etch, php5, cakephp 1.2, postgresql
>
> > I think its my configuration thats the cause, but am stuck
>
> > any ideas please
> > Cheers
> > Phil
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Creating and persisting objects independent of the controller

2007-12-04 Thread Deane

If I want to create an object, set some properties, and save it, can I
do this in my controller:

$MyObject = new ThingaMajig();
$MyObject->some_property = "some value";
$MyObject->save()

This object has nothing to do with my controller.  This just needs to
happen in one of the methods.

We've tried this, and Cake seems to ignore it.  It runs through the
code (code on either side of it runs), but this code does not result
in any SQL or any database record.

--~--~-~--~~~---~--~~
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: Caching the view of the entry homepage

2007-12-04 Thread Dave J

Thanks for the replies.

I ended up settling for the redirect option for the short term fix.

@Adam: Neat workaround, wish I thought about it earlier...  just not
the right time to start splitting down the homepage into elements
right now :-)

@Matt: I can understand your pain, especially the homepage getting the
most hits of the entire site, and being the only page not relying on a
view cache.. hopefully will be sorted out soon
--~--~-~--~~~---~--~~
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: Stop Users From Going Back After Logout

2007-12-04 Thread Joyce

I see. Hopefully I can get what you mean by that.

I will give it a shot. Thanks.

On Dec 5, 2:31 am, "Chris Hartjes" <[EMAIL PROTECTED]> wrote:
> On Dec 4, 2007 1:26 PM, Joyce <[EMAIL PROTECTED]> wrote:
>
>
>
> > Thanks Chris,
>
> > I will look through your tutorials. I am using CakePHP 1.1, can that
> > work?
>
> The Auth component is not available in 1.2, but I believe you can use
> the Security component to do similar things.
>
> --
> Chris Hartjes
>
> My motto for 2007:  "Just build it, damnit!"
>
> @TheKeyboard -http://www.littlehart.net/atthekeyboard
--~--~-~--~~~---~--~~
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: German user group?

2007-12-04 Thread Daniel Hofstetter

Hi Powtac,

> Is there a german speaking cakePHP user group / forum?

http://groups.google.com/group/cakephp-de

--
Daniel Hofstetter
http://cakebaker.42dh.com
--~--~-~--~~~---~--~~
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: Stop Users From Going Back After Logout

2007-12-04 Thread Chris Hartjes

On Dec 4, 2007 1:26 PM, Joyce <[EMAIL PROTECTED]> wrote:
>
> Thanks Chris,
>
> I will look through your tutorials. I am using CakePHP 1.1, can that
> work?

The Auth component is not available in 1.2, but I believe you can use
the Security component to do similar things.

-- 
Chris Hartjes

My motto for 2007:  "Just build it, damnit!"

@TheKeyboard - http://www.littlehart.net/atthekeyboard

--~--~-~--~~~---~--~~
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: Stop Users From Going Back After Logout

2007-12-04 Thread Joyce

Thanks Chris,

I will look through your tutorials. I am using CakePHP 1.1, can that
work?


On Dec 5, 2:11 am, "Chris Hartjes" <[EMAIL PROTECTED]> wrote:
> On Dec 4, 2007 12:49 PM, Joyce <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi,
>
> > I have question regarding how to prevent users from going back to the
> > application after they have logout.
>
> I suggest you use the Auth component if you are using CakePHP 1.2.
> Since I'm a shameless self-promotor, there are two tutorials on using
> the Auth component on my blog.
>
> --
> Chris Hartjes
>
> My motto for 2007:  "Just build it, damnit!"
>
> @TheKeyboard -http://www.littlehart.net/atthekeyboard
--~--~-~--~~~---~--~~
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: Stop Users From Going Back After Logout

2007-12-04 Thread Joyce

The thing is that it is not a blank page. It contains the value of
whatever details that is seen as per when he logged in.

On Dec 5, 2:15 am, kiger <[EMAIL PROTECTED]> wrote:
> Why does it matter? If you delete the session storing the user data,
> then pressing back might bring him to a blank page, but who cares?
>
> On Dec 4, 12:49 pm, Joyce <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I have question regarding how to prevent users from going back to the
> > application after they have logout.
>
> > Below is my index and logout for userscontroller:
> > function index() {
> > $this->checkSession();
> > if ($this->Session->check('user')) {
> > $this->User->recursive = 0;
> > $this->set('users', $this->User->findAll());
> > } else {
> > $this->redirect('/');
> > }
>
> > }
>
> > function logout() {
> > $this->Session->delete('user');
> > $this->Session-> destroy();
> > $this->redirect('/');
>
> > }
>
> > But I still am not able to stop users from clicking on the browser's
> > back button, and yet still able to see the index page even after they
> > have logout. Would anyone be able to point out what am I missing?
>
> > 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: Stop Users From Going Back After Logout

2007-12-04 Thread kiger

Why does it matter? If you delete the session storing the user data,
then pressing back might bring him to a blank page, but who cares?

On Dec 4, 12:49 pm, Joyce <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have question regarding how to prevent users from going back to the
> application after they have logout.
>
> Below is my index and logout for userscontroller:
> function index() {
> $this->checkSession();
> if ($this->Session->check('user')) {
> $this->User->recursive = 0;
> $this->set('users', $this->User->findAll());
> } else {
> $this->redirect('/');
> }
>
> }
>
> function logout() {
> $this->Session->delete('user');
> $this->Session-> destroy();
> $this->redirect('/');
>
> }
>
> But I still am not able to stop users from clicking on the browser's
> back button, and yet still able to see the index page even after they
> have logout. Would anyone be able to point out what am I missing?
>
> 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: Error: Cake bake to generate model

2007-12-04 Thread Steveston



On Dec 4, 4:26 am, AD7six <[EMAIL PROTECTED]> wrote:
> On Dec 4, 9:49 am, Steveston <[EMAIL PROTECTED]> wrote:
>
>
>
> > I am using the latest pre-beta 1.2.x version. When trying to bake
> > models, get this error:
>
> > Possible Models based on your current database:
> > 1. CourseComment
> > 2. CourseInstructor
> > 3. Course
> > 4. Instructor
> > 5. Source
> > 6. TextbookComment
> > 7. Textbook
> > 8. User
> > 9. UsersTextbook
> > Enter a number from the list above, or type in the name of another
> > model.> 1
>
> > Would you like to supply validation criteria for the fields in your
> > model? (y/n)
>
> > [y] > n
> > PHP Fatal error:  ConnectionManager::getDataSource - Non-existent data
> > source de
> > fault in C:\apache224\htdocs\book\cake\libs\model
> > \connection_manager.php on line
> >  110
>
> > Fatal error: ConnectionManager::getDataSource - Non-existent data
> > source default
> >  in C:\apache224\htdocs\book\cake\libs\model\connection_manager.php on
> > line 110
>
> > Why?
>
> Do you have a default datasource in your database.php? If not create
> one as cake expects and relies (iirc) on a default datasource being
> present.
>
> hth,
>
> AD

Yes.

I have modifed app/config/database.php to fit my db settings.
--~--~-~--~~~---~--~~
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: Stop Users From Going Back After Logout

2007-12-04 Thread Chris Hartjes

On Dec 4, 2007 12:49 PM, Joyce <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I have question regarding how to prevent users from going back to the
> application after they have logout.
>

I suggest you use the Auth component if you are using CakePHP 1.2.
Since I'm a shameless self-promotor, there are two tutorials on using
the Auth component on my blog.


-- 
Chris Hartjes

My motto for 2007:  "Just build it, damnit!"

@TheKeyboard - http://www.littlehart.net/atthekeyboard

--~--~-~--~~~---~--~~
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: Inline javascript in a view not executed

2007-12-04 Thread Christophe Cholot



On Dec 4, 5:22 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hi I have a question
> I have a index.thml where there are many divs.
> Then with ajax I substitute one of divs with another view
> ( view.thtml).
> In this view I use a javascript function  attached to a link.
> So If I define this function in view.thtml I get an error instead I
> define the function in index.html all works fine.
> But I would define the function in view.thtml because I use this
> function only in this view.
> How I can do This ?
> Many Thanks
> Marco

Hello,

What Javascript library are you using ?

With prototype, if think you can set evalScripts to true as an option
when using Ajax.Request. You can also play with onSuccess callback to
get things done.

I hope it helps !

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



Stop Users From Going Back After Logout

2007-12-04 Thread Joyce

Hi,

I have question regarding how to prevent users from going back to the
application after they have logout.

Below is my index and logout for userscontroller:
function index() {
$this->checkSession();
if ($this->Session->check('user')) {
$this->User->recursive = 0;
$this->set('users', $this->User->findAll());
} else {
$this->redirect('/');
}
}

function logout() {
$this->Session->delete('user');
$this->Session-> destroy();
$this->redirect('/');
}

But I still am not able to stop users from clicking on the browser's
back button, and yet still able to see the index page even after they
have logout. Would anyone be able to point out what am I missing?

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



German user group?

2007-12-04 Thread powtac

Is there a german speaking cakePHP user group / forum?
--~--~-~--~~~---~--~~
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: Return Helper Output as variable (not echo)

2007-12-04 Thread Mike Digital Egg

Hi Dordo,

You are right that the ajax->link method does not echo the result, but
if you put it within a custom helper method it does. Not sure why but
I just took it out of the helper and put it directly in the view and
it has worked. I will try and work out why it doesn't work in the
helper when I have some more time.

Thanks for the help it just kicked some wheels in my brain in to
gear :)

Cheers

Mike

On Dec 4, 5:49 pm, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote:
> If you look at it:http://api.cakephp.org/1.2/ajax_8php-source.html,
> the link method returns the output, it doesn't print.
>
> On Dec 4, 2007 1:37 PM, Mike Digital Egg <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi,
> > I need to take some output from a helper and put it into a variable
> > rather than echoing it to screen, is this possible with Cake 1.2?
>
> > eg.
> > Helper Function: links.php
> > [code]
> > function return_link() {
> > $output = $this->Ajax->link(__('return_link',true),'/
> > index',array('update' => 'pagecontent','loading' =>
> > "loading();showMenu();",'complete' => "complete();"),null,false);
> > return $output;
> > }
> > [/code]
> > Page View
> > [code]
> > return_link(); ?>
> > [/code]
>
> > Doing this prints the link to screen (which I don't want it to do).
>
> > Any ideas?
>
> > Cheers
>
> > Mike
--~--~-~--~~~---~--~~
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: Xml layout name

2007-12-04 Thread Andreas

I used this one and it works.

$this->layoutPath = 'xml';
$this->layout = 'default';

I'm wondering though why have they even bothered putting them into a
folder in the first place?

Thanks for the help!

On Dec 4, 2:10 am, snowdog <[EMAIL PROTECTED]> wrote:
> Or you can set Router::parseExtensions('xml'), then you dont have to
> specify layout, cake will take care of it
--~--~-~--~~~---~--~~
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: Return Helper Output as variable (not echo)

2007-12-04 Thread Dardo Sordi Bogado

If you look at it: http://api.cakephp.org/1.2/ajax_8php-source.html ,
the link method returns the output, it doesn't print.

On Dec 4, 2007 1:37 PM, Mike Digital Egg <[EMAIL PROTECTED]> wrote:
>
> Hi,
> I need to take some output from a helper and put it into a variable
> rather than echoing it to screen, is this possible with Cake 1.2?
>
> eg.
> Helper Function: links.php
> [code]
> function return_link() {
> $output = $this->Ajax->link(__('return_link',true),'/
> index',array('update' => 'pagecontent','loading' =>
> "loading();showMenu();",'complete' => "complete();"),null,false);
> return $output;
> }
> [/code]
> Page View
> [code]
> return_link(); ?>
> [/code]
>
> Doing this prints the link to screen (which I don't want it to do).
>
> Any ideas?
>
> Cheers
>
> Mike
> >
>

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



Return Helper Output as variable (not echo)

2007-12-04 Thread Mike Digital Egg

Hi,
I need to take some output from a helper and put it into a variable
rather than echoing it to screen, is this possible with Cake 1.2?

eg.
Helper Function: links.php
[code]
function return_link() {
$output = $this->Ajax->link(__('return_link',true),'/
index',array('update' => 'pagecontent','loading' =>
"loading();showMenu();",'complete' => "complete();"),null,false);
return $output;
}
[/code]
Page View
[code]
return_link(); ?>
[/code]

Doing this prints the link to screen (which I don't want it to do).

Any ideas?

Cheers

Mike
--~--~-~--~~~---~--~~
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: Caching the view of the entry homepage

2007-12-04 Thread MattC

This bug is probably the most frustrating thing about Cake for me.  I
had been using the fix described in the ticket (http://
trac.cakephp.org/ticket/1349).  I rolled the change into a patch that
matches the latest SVN and is slightly more configurable then the
original fix.  It's attached to the ticket.

-Matt
www.pseudocoder.com
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Inline javascript in a view not executed

2007-12-04 Thread [EMAIL PROTECTED]

Hi I have a question
I have a index.thml where there are many divs.
Then with ajax I substitute one of divs with another view
( view.thtml).
In this view I use a javascript function  attached to a link.
So If I define this function in view.thtml I get an error instead I
define the function in index.html all works fine.
But I would define the function in view.thtml because I use this
function only in this view.
How I can do This ?
Many Thanks
Marco


--~--~-~--~~~---~--~~
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: Reuse of code via elements, requestAction etc.

2007-12-04 Thread AD7six



On Dec 4, 4:17 pm, sunertl <[EMAIL PROTECTED]> wrote:
> I have a question concerning the reusage of code in cakephp. as far as
> i understood the optimum to reach in mvc-frameworks is that no code is
> written twice. cake gives me means like elements and requestAction to
> reach this goal.
>
> but: every requestAction results in a new http-request, for elements i
> do not know. so i am concerned if i trade reusage for performance. is
> it better to write the few lines for pagination in every index-view
> (like created by bake) or write one element i call from there.
> the views created by bake include tables of related models. would it
> be better to requestAction index (with an aditional parameter
> containing the foreign key) from the related model? i think you can
> find dozens of situations like that.
>
> is there a limit like "not more than 5 requestActions and 3 elements
> per page" for best performance or should they be used all over to get
> best reusage of code?
>
> thank you in advance for your help!

I don't think there is any noticable performance hit at all using
elements, if you can restructure your code to not need to use
requestAction, it'll be in your interest to do so.

Or in other words optimal:
elements = unlimited;
requestAction = 0;

IMO hth,

AD
PS mini controllers on the frequent discussions page.
--~--~-~--~~~---~--~~
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: Easy referential data integrity?

2007-12-04 Thread [EMAIL PROTECTED]

awesome, thanks! I can't believe I missed that.

On Dec 3, 10:58 pm, Grant Cox <[EMAIL PROTECTED]> wrote:
> Set 'dependent'=>true in your $hasMany definition.  
> Seehttp://manual.cakephp.org/chapter/modelsfor more details.
>
> On Dec 4, 2:56 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
> > Hi, I'm new to cakePHP and I'm wondering if there is an easy way to
> > setup automatic referential data integrity so that when I delete a
> > parent, all of it's children are automatically deleted? Right now I
> > have a $hasMany relationship setup in the parent's model and a
> > $belongsTo relationship setup in the child's model. As it is now, when
> > I delete a parent data objects, it's children are not deleted. If you
> > know how to do this, other then manually deleting all of the children
> > in the parents delete function, let me know.
>
> > Thanks,
> > Dave

--~--~-~--~~~---~--~~
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: Reuse of code via elements, requestAction etc.

2007-12-04 Thread Adam Royle

Open-ended answer... sorry :)

I would say do whatever is easiest and maintainable for *YOU*.

There are ways to speed up requestActions inside elements by using
caching where possible.

Since most applications are different in nature in terms of
requirements, one size does not fit all.

If you find yourself using the same code over and over again with
minimal changes, then maybe look into making it into a helper, or
behaviour, or a component, or add it in beforeFilter(), afterFilter(),
depending on what the code actually does.

But as long as you keep revisiting and revising the code you write,
you will soon figure out what suits you best on a variety of projects.
As you do this you will also gain a better understanding of cakephp
and what it can offer you.

Cheers,
Adam

On Dec 5, 1:17 am, sunertl <[EMAIL PROTECTED]> wrote:
> I have a question concerning the reusage of code in cakephp. as far as
> i understood the optimum to reach in mvc-frameworks is that no code is
> written twice. cake gives me means like elements and requestAction to
> reach this goal.
>
> but: every requestAction results in a new http-request, for elements i
> do not know. so i am concerned if i trade reusage for performance. is
> it better to write the few lines for pagination in every index-view
> (like created by bake) or write one element i call from there.
> the views created by bake include tables of related models. would it
> be better to requestAction index (with an aditional parameter
> containing the foreign key) from the related model? i think you can
> find dozens of situations like that.
>
> is there a limit like "not more than 5 requestActions and 3 elements
> per page" for best performance or should they be used all over to get
> best reusage of code?
>
> thank you in advance for your help!
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



i18n: static language references with __("My lang key", true) in models and controllers

2007-12-04 Thread cakeFreak

Hey guys,

is there a way to use i18n style static language references  __("My
lang key", true) in models and controllers like for example:

$test = __("My lang key", true);

When I try to do it this way I get a syntax error in my code.

cheers

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



Reuse of code via elements, requestAction etc.

2007-12-04 Thread sunertl

I have a question concerning the reusage of code in cakephp. as far as
i understood the optimum to reach in mvc-frameworks is that no code is
written twice. cake gives me means like elements and requestAction to
reach this goal.

but: every requestAction results in a new http-request, for elements i
do not know. so i am concerned if i trade reusage for performance. is
it better to write the few lines for pagination in every index-view
(like created by bake) or write one element i call from there.
the views created by bake include tables of related models. would it
be better to requestAction index (with an aditional parameter
containing the foreign key) from the related model? i think you can
find dozens of situations like that.

is there a limit like "not more than 5 requestActions and 3 elements
per page" for best performance or should they be used all over to get
best reusage of code?

thank you in advance for your help!
--~--~-~--~~~---~--~~
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: Save doesn't work with Postgres

2007-12-04 Thread Rhee

Thanks for the answer ...

Then I'd rather use SQL INSERT / UPDATE statement. I just don't want
to change anything on the Cake source ... ;-)

On Dec 1, 9:02 pm, "Adrian Maier" <[EMAIL PROTECTED]> wrote:
> On Nov 30, 2007 12:01 PM, Rhee <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
>
>
>
>
> > No one has ever this problem?
>
> > On Nov 29, 12:17 pm, Rhee <[EMAIL PROTECTED]> wrote:
> > > Does anybody have problem to use Save function with Postgres?
> > > Everytime I call $this->Model->save($this->data) I get the following
> > > notice messages (repeated 4 times):
>
> > > Notice: Undefined index: name in /var/www/htdocs/sid/cake/libs/model/
> > > dbo/dbo_postgres.php on line 350
>
> > > and then:
> > > Warning: Cannot modify header information - headers already sent by
> > > (output started at /var/www/htdocs/sid/cake/libs/model/dbo/
> > > dbo_postgres.php:350) in /var/www/htdocs/sid/cake/libs/controller/
> > > controller.php on line 447
>
> > > Basically the data were saved into database.
>
> > > It works well at production level. I believe in this level all notices
> > > and warnings were suppressed, so it looks like to work perfectly.
> > > Right now, to avoid the notices I use $this->Model->execute($sql);
> > > where $sql is an SQL INSERT INTO or UPDATE statement.
>
> > > I still use Cake v 0.2.9.4409. The same version works well with MySQL.
>
> > > Any idea to resolve this, except with execute() or maybe upgrade Cake?
>
> Hello,
>
> I've encountered the same error when using a PostgreSQL database.  It's a
> bug that has been very recently solved .
>
> Instead of upgrading, i've simply duplicated the fix on the version of cakephp
> i was using . The fix is a trivial one:   open the dbo_postgres.php  ,
> go to line 350
> and modify this "if" statement :
>
>  if (strcasecmp($sourceinfo['name'], $field) == 0) {
> break;
>  }
>
> to this :
>
>  if (  isset($sourceinfo['name']) &&
> strcasecmp($sourceinfo['name'], $field) == 0)   {
> break;
>  }
>
> You could also try to upgrade to a newer cake , but i'm not sure which
> is the first version
> that includes this particular bug fix.
>
> Cheers,
> Adrian Maier

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



dbdesigner2cake : DBDesigner 4 Scaffold Tools for CakePHP - 1.0.5 - Minor Bug Release

2007-12-04 Thread Dérico Filho

Hello All,

A minor bug release of dbdesigner2cake is available. Those who are
using the release 1.0.4 are recommended to upgrade to 1.0.5.

A small bug on a global variables turned the new parameter -core
almost useless.

DBDesigner 4 Scaffold Tools for CakePHP, or simply dbdesigner2cake, is
a tool which parses fabFORCE's DBDesigner 4 XML file into CakePHP
models and controllers files.

It aims to simplify the first two steps in any system development,
modelling and model coding.

Well, as I usually finish such release notes:

You are welcome to download the 1.0.5 version at
http://dbdesigner2cake.cirello.org/download.html

Bye

Dérico Filho
--~--~-~--~~~---~--~~
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 table

2007-12-04 Thread Adam Royle

Ahhh... I think I now understand what you're saying. Initially I
thought you meant creating tables in the actual database and I'm
sure everyone else thought the same.

But re-reading your question I now think you mean *HTML* tables. Is
that correct?

OK... I would achieve the effect you want using ajax...

Here is the code you would put in your view for model A. You could
probably do the same with cakephp helpers but this is easy enough to
understand.


/views/modela/add.ctp



function addB(){
new Ajax.Updater('mytable', '/ModelB/blank_row/',
{insertion:Insertion.Bottom});
}



create('ModelA') ?>









end() ?>









And then in your view you would output the new row like so

/views/modelb/blank_row.ctp


create("ModelB.field1") ?>
create("ModelB.field2") ?>
create("ModelB.field3") ?>



And that code should fit together nicely

HOWEVER the only thing left to consider is making sure the field
names and ids are not duplicated and are in a format cakephp can
handle when saving.

(note: cakephp doesn't automatically save hasMany associations... so
you'll need the saveHasMany() function included at the bottom of this
email.)


The saveHasMany() function expects form input field names to be in a
format like this:










Unfortunately in the blank_row.ctp above the form helper will create
fields like this.. which will obviously not work...



The way to solve this is to pass an extra argument when requesting the
blank row, using javascript to keep track of the counter_var.. eg


var counter_var = 0;
function addB(){
new Ajax.Updater('mytable', '/modelb/blank_row/'+(counter_var++),
{insertion:Insertion.Bottom});
}


Then modify your controller to pass this through to the view to use.

function blank_row($index){
$this->set('index', intval($index));
}

(another note: currently you can't overwrite the fieldname when using
the form helper, so my suggestion is to overwrite the $form->Html-
>tags['***'] array)

Html->tags['input'] = '';
$form->Html->tags['hidden'] = '';

// ... you get the idea... you can find the rest defined inside /cake/
libs/view/helpers/html.php

?>

input('field1', array('id' => 'ModelB'.
$index.'field1')); ?>
input('field2', array('id' => 'ModelB'.
$index.'field2')); ?>
input('field3', array('id' => 'ModelB'.
$index.'field3')); ?>







And finally here is the saveHasMany() method that goes into your
app_model.php file

class AppModel extends Model {

function saveHasMany($k) {
$success = true;

$v = $this->hasMany[$k];

$myid = $this->data[$this->name][$this->primaryKey] ? $this-
>data[$this->name][$this->primaryKey] : $this->id;
$deletequery = "DELETE FROM {$this->$k->useTable} WHERE
{$v['foreignKey']} = {$myid}";
$db =& ConnectionManager::getDataSource($this->$k->useDbConfig);
$db->query($deletequery);

if (!isset($this->data[$k]) || empty($this->data[$k])) {
return $success;
}

// Save new data
foreach ($this->data[$k] as $tc) {
$tc[$v['foreignKey']] = $myid;
$data[$v['className']] = $tc;
$this->{$v['className']}->create($data);
if (!$this->{$v['className']}->save()) {
$success = false;
}
}

return $success;
}

}


and use it in your model like:

class ModelA extends AppModel {

... blah associations, etc ...

function afterSave(){
$this->saveHasMany('ModelB');
}

}


On Dec 4, 9:03 pm, dandreta <[EMAIL PROTECTED]> wrote:
> Nobody knows any link or example how I can do it?
--~--~-~--~~~---~--~~
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: Default Admin Routing for Forms in 1.2 Pre Beta

2007-12-04 Thread Bruno Bergher

Worked like a charm! Thanks a lot.
Maybe it's just an isolated case, but I find it weird to have a pre-
beta release that is less stable than the alpha one.
But baking is gonig great; I have no complains whatsoever.

Bruno

On Dec 1, 12:04 am, Bruno Bergher <[EMAIL PROTECTED]> wrote:
> Thanks a lot, people. I'll get to it on Monday and comment on the
> solution.
>
> On Nov 30, 2:34 am, Kalileo <[EMAIL PROTECTED]> wrote:
>
> > I have suffered the same problems, but fear not, they are solved:
>
> > There have been a few bugs which are all been fixed in the meantime.
> > These fixes are already in the svn. Not in trunk though, but in
> > branches. Take that and it will work again.
>
> > If you have a modern OS, such as Linux, do something like
> > svn cohttps://svn.cakephp.org/repo/branches/1.2.x.x
> > cakephp_svn_branches
> > or better
> > svn exporthttps://svn.cakephp.org/repo/branches/1.2.x.x
> > cakephp_svn_branches
>
> > and it will download the latest svn branches code for you to the
> > subdirectory cakephp_svn_branches
>
> > Alternatively you could search trac for the bugfixes concerning admin
> > routing and implement them yourself 
>
> > HTH
> > Kalileo
>
> >BrunoBergher wrote:
> > > Hi everyone!
>
> > > We just moved an application we developed in 1.2.0.5427 alpha to the
> > > latest pre beta release. Everything worked fine except for just one
> > > thing:
>
> > > In admin 'edit' actions, FormHelper is being supplied with wrong
> > > action URLs. With index, view, add and deletr actions, there's
> > > absolutely no problem. With 'edit' actions, the form is created
> > > without our admin path in the URL. Out 'Routing.admin' configuration
> > > is set to 'publisher'.
>
> > > For example:
> > > When accessing through the browser URL '/publisher/posts/add', the
> > > form action is properly set to '/publisher/posts/add'.
> > > When accessing through the browser URL '/publisher/posts/edit/4', the
> > > form action is set to '/posts/edit/4', missing the admin portion of
> > > it.
>
> > > What I have found out so far:
>
> > > In router.php, line 676, if I replace
> > > $url[$admin] = true;
> > > with
> > > $url['admin'] = true;
> > > it works, while appending 'admin:1' to the URL.
> > > This is not great news, but might help.
>
> > > If I change my 'Routing.admin' setting to 'admin' (and rename the
> > > controller action and view filename to admin_), it also works.
>
> > > I believe the problem probably lies in Router::url(), line 700. The
> > > 'add' action sets $match to true, but the 'edit' action, for reason,
> > > does not.
> > > I havo also tried adding a mock id to the url (/publisher/posts/add/4)
> > > to see if it helps, but with no success.
>
> > > We've been struggling with this for while, and any help would be
> > > greatly appreciated.
>
> > > Thanks in advance!
>
> > > Best,
>
> > >Bruno

--~--~-~--~~~---~--~~
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: Error: Cake bake to generate model

2007-12-04 Thread AD7six



On Dec 4, 9:49 am, Steveston <[EMAIL PROTECTED]> wrote:
> I am using the latest pre-beta 1.2.x version. When trying to bake
> models, get this error:
>
> Possible Models based on your current database:
> 1. CourseComment
> 2. CourseInstructor
> 3. Course
> 4. Instructor
> 5. Source
> 6. TextbookComment
> 7. Textbook
> 8. User
> 9. UsersTextbook
> Enter a number from the list above, or type in the name of another
> model.> 1
>
> Would you like to supply validation criteria for the fields in your
> model? (y/n)
>
> [y] > n
> PHP Fatal error:  ConnectionManager::getDataSource - Non-existent data
> source de
> fault in C:\apache224\htdocs\book\cake\libs\model
> \connection_manager.php on line
>  110
>
> Fatal error: ConnectionManager::getDataSource - Non-existent data
> source default
>  in C:\apache224\htdocs\book\cake\libs\model\connection_manager.php on
> line 110
>
> Why?

Do you have a default datasource in your database.php? If not create
one as cake expects and relies (iirc) on a default datasource being
present.

hth,

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

2007-12-04 Thread dandreta

Nobody knows any link or example how I can do it?

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



Sending array with html helper

2007-12-04 Thread Smart_Weird

Hi all,

I want to send array with html helper

i.e. when i write this with plain html, I receive answers array in
post:




but with when I write with html helper, I just receive the last one
$html->input('Coursequizquestion/answers[]', array('size' => '60'));
$html->input('Coursequizquestion/answers[]', array('size' => '60'));
$html->input('Coursequizquestion/answers[]', array('size' => '60'));

anyone got solution ?

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: textarea formating

2007-12-04 Thread manu

Hello Michael,

thank you, it works!

I could have searched for days to find that!
btw I found a function nl2br($body) which does the same thing

Best regards

Manu




On 4 déc, 08:47, schneimi <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I think your problem is the '\n', because that way the line feed
> doesn't get interpreted, try it with "\n" instead.
>
> Best regards,
>
> Michael
>
> manu schrieb:
>
> > Hello all,
>
> > I'm new to cake (and php btw).
> > I'm looking for a way to format a plain textarea text in html. I don't
> > want to use an html editor, but just want something like this:
>
> > ', $body); ?> but it doesn't work.
>
> > Is there a cake helper, or method which could do that? Is there
> > another php way to do it?
>
> > Thanks for helping
>
> > Ma

--~--~-~--~~~---~--~~
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: textarea formating

2007-12-04 Thread manu

Hello Michael,

It's perfectly true, '\n' doesn't work
it could have taken me days to find that!

I also found a php function nl2br($body) which does the same thing

thank you all

Manu



On 4 déc, 08:47, schneimi <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I think your problem is the '\n', because that way the line feed
> doesn't get interpreted, try it with "\n" instead.
>
> Best regards,
>
> Michael
>
> manu schrieb:
>
> > Hello all,
>
> > I'm new to cake (and php btw).
> > I'm looking for a way to format a plain textarea text in html. I don't
> > want to use an html editor, but just want something like this:
>
> > ', $body); ?> but it doesn't work.
>
> > Is there a cake helper, or method which could do that? Is there
> > another php way to do it?
>
> > Thanks for helping
>
> > Manu

--~--~-~--~~~---~--~~
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: textarea formating

2007-12-04 Thread manu

thanks Michael,

I could have searched that for ages.
and nl2br() is just fine too

Best regards

Manu


On 4 déc, 10:24, grigri <[EMAIL PROTECTED]> wrote:
> What's wrong with nl2br() ?
>
> On Dec 4, 7:47 am, schneimi <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I think your problem is the '\n', because that way the line feed
> > doesn't get interpreted, try it with "\n" instead.
>
> > Best regards,
>
> > Michael
>
> > manu schrieb:
>
> > > Hello all,
>
> > > I'm new to cake (and php btw).
> > > I'm looking for a way to format a plain textarea text in html. I don't
> > > want to use an html editor, but just want something like this:
>
> > > ', $body); ?> but it doesn't work.
>
> > > Is there a cake helper, or method which could do that? Is there
> > > another php way to do it?
>
> > > Thanks for helping
>
> > > Manu

--~--~-~--~~~---~--~~
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: textarea formating

2007-12-04 Thread grigri

What's wrong with nl2br() ?

On Dec 4, 7:47 am, schneimi <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I think your problem is the '\n', because that way the line feed
> doesn't get interpreted, try it with "\n" instead.
>
> Best regards,
>
> Michael
>
> manu schrieb:
>
> > Hello all,
>
> > I'm new to cake (and php btw).
> > I'm looking for a way to format a plain textarea text in html. I don't
> > want to use an html editor, but just want something like this:
>
> > ', $body); ?> but it doesn't work.
>
> > Is there a cake helper, or method which could do that? Is there
> > another php way to do it?
>
> > Thanks for helping
>
> > Manu
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Error: Cake bake to generate model

2007-12-04 Thread Steveston

I am using the latest pre-beta 1.2.x version. When trying to bake
models, get this error:

Possible Models based on your current database:
1. CourseComment
2. CourseInstructor
3. Course
4. Instructor
5. Source
6. TextbookComment
7. Textbook
8. User
9. UsersTextbook
Enter a number from the list above, or type in the name of another
model.
> 1
Would you like to supply validation criteria for the fields in your
model? (y/n)

[y] > n
PHP Fatal error:  ConnectionManager::getDataSource - Non-existent data
source de
fault in C:\apache224\htdocs\book\cake\libs\model
\connection_manager.php on line
 110

Fatal error: ConnectionManager::getDataSource - Non-existent data
source default
 in C:\apache224\htdocs\book\cake\libs\model\connection_manager.php on
line 110

Why?
--~--~-~--~~~---~--~~
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: I'm having problems with associations...

2007-12-04 Thread Serge Rodovnichenko

1. Add $primaryKey = 'zip'; in Zipcode model.
2. Define 'foreignKey'=>'zip' in $hasMany association.
3. Your associations should looks like: User belogsTo Zip, Zip hasMany
Users.


On Dec 4, 9:02 am, Jon Hinson <[EMAIL PROTECTED]> wrote:
> Ok, I can't seem to solve this problem for the life of me. I have a
> User model and a Zipcode model. Zipcode hasMany users. I want them to
> join on User.zip = Zipcode.zip. I have to join on Zipcode.zip and not
> Zipcode.id because a zipcode can have many rows because of several
> city names, etc. I know this is not normalized, but it is much easier
> like this. So I have a hasMany association that looks like this:
>
> var $hasMany = array('User' =>
> array('className'=> 'User',
>   'conditions'   => '',
>   'order'=> '',
>   'dependent'=>  true,
>   'foreignKey'   => '',
>   'finderQuery'  => '
> SELECT *
>   
>   FROM users as User
>   
>   JOIN zipcodes as Zipcode ON (User.zip = Zipcode.zip)'
> )
>   );
>
> I tried using the finderQuery after doing foreignKey => 'zip' didn't
> work. I also had a belongsTo Zipcode in User with foreignKey =>
> 'zip' :
>
> var $belongsTo = array('Zipcode' =>
> array('className'=> 'Zipcode',
>   'conditions'   => '',
>   'order'=> '',
>   'dependent'=>  true,
>   'foreignKey'   => 
> 'zip'
> )
>   );
>
> With everything that I've tried, when I do a $this->Zipcode->User->findAll, 
> or try to paginate with $this->Zipcode->User, it tries to
>
> join on User.zip = Zipcode.id instead of Zipcode.zip.
>
> Any help is much appreciated.
> Jon
>
> PS- I'm using Cake 1.2
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---