Many-to-Many Relationships with 3 tables. Auth and Acl

2008-08-18 Thread Reza Muhammad

Hi All,

I've been following lately, and I must say I'm very pleased with the  
framework.  Currently, I'm having a different project where there  
should be many to many relationships between 3 tables.

This particular situation is for user management purposes.  The User  
role /group will depend on the clients she/he handles.  For example,  
user A belongs to group Administrator when dealing with data from  
client 1, however user A belongs to 'limited user' when dealing with  
data from client 2.  So, one user can have many groups depending on  
the client, and users can also have more than 1 role in the same client.

The scenario is:
- One User has many groups.
- One group has many users.
- One client has many groups_users.

Can someone help me out how do I do this with CakePHP?  I was thinking  
to have a many-to-many relationships between User and Group, so there  
will be an additional table called groups_users.  However, can I also  
make many-to-many relationship between "groups_users" and "clients" ?  
Will it be called "clients_groups_users"? How about the column in this  
table? Would it only be groups_users_id, and client_id?

I was also thinking to have Acl.  Would this be possible?

Or, is there any simpler solution to this?

Thank you for your help


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



Re: Thoughts on translation strings.

2008-08-18 Thread [EMAIL PROTECTED]

Thanks for your replies guys.
I had managed to track down the guidelines at gnu.org but the other
ones were new to me.

/Martin


On Aug 15, 1:23 pm, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote:
> > But how much real text should I put in each string? I could just as
> > easily translate:
> > "Your data" "was saved" or
> > "Your" "data" "was" "saved"
>
> > Should I try to keep these strings short to avoid duplication, i.e.
> > keep things DRY, or make them long to give copy writing the ability to
> > use specific phrasing for specific tasks?
>
> Use complete readable strings, DRY don't apply in translation because
> it makes things really difficult (if not impossible) for translators.
>
> References:
>
> http://www.gnu.org/software/gettext/manual/gettext.html#Preparing-Str...http://www.w3.org/International/articles/composite-messages/
>
> - Dardo Sordi
>
> > So, what happens when you want to alter the phrasing of your default
> > language? Possibly radically alter it.
> > An alternative that can be preferable in some cases is to have the
> > msgids actually be unique ids.
> > "app_flash_data_save" or
> > "upload_save_ok_flash"
> > might be what is translated into
> > "Your data was saved"
>
> > Using ids here would have some similar benefits and problems to the
> > ids used in SQL databases. I said some, not all. They contain no real
> > text so you can totally alter the copywriting of your application at
> > any point. The down side is that you will definitely have more and
> > longer string in your .po files, and more duplication of words (if
> > that is even a problem).
>
> > I have been playing around with different approaches and can honestly
> > not say I have found the one true way of organizing my strings. I
> > quite like using ids since they give indicate in the translation file
> > how and where the string will be used. It also helps me not think
> > about an applications "tone of voice" while I am in the middle of
> > coding a new feature. I can focus on that when I put on my copywriter
> > hat (or preferably sit down with a real pro).
>
> > I also like the speed and simplicity of just enclosing normal text in
> > the translation function and move on... I can worry about German
> > translations when I get my first customer from Germany. My application
> > will not even need a .po file untill I do my first translation. But
> > being from a non-English-speaking country I usually have two languages
> > even from the start unless I am lazy:)
>
> > Well, those are my current thought on this subject. I think it is a
> > subject that we could all think about a bit more. Come to think about
> > it. There will probably be thousands of insightful blog-posts about
> > this if I jusr google for it :)... oh well.
>
> > /Martin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



How to get the category cover from a product table?

2008-08-18 Thread Henrique Machado

Hello!
This is my first messa ge here.
Sorry my bad english, i'm from brazil

Scenario:

Category hasMany Products
Products belongsTo Category

category table:

  `id` int(10) unsigned NOT NULL auto_increment,
  `nome` varchar(255) collate utf8_unicode_ci default NULL,
  `created` datetime default NULL,
  `slug` varchar(255) collate utf8_unicode_ci default NULL,
  `imgcover` int(11) NOT NULL,
  PRIMARY KEY  (`id`)

products:

  `id` int(10) unsigned NOT NULL auto_increment,
  `imgpath varchar(255) collate utf8_unicode_ci default NULL,
  `legend` varchar(255) collate utf8_unicode_ci default NULL,
  `created` datetime default NULL,
  `slug` varchar(255) collate utf8_unicode_ci default NULL,
  `category_id` int(10) unsigned default NULL,
  PRIMARY KEY  (`id`),
  KEY `fotos_obra` (`obra_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
AUTO_INCREMENT=27 ;


My problem: I need to show the imgcover (is the product id) in my
category index:
function index() {
$this->Category->recursive = 1;
$this->set('categories', $this->paginate());
}

The "php" way is do an foreach categories and loop each cagotegory to
do something like: SELECT imgpath FROM PRODUCTS WHERE id =
category.imgcover

But, in the cake way?


Thanks

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



Re: 2 column layout for $form->input() ?

2008-08-18 Thread peterm95018


Would it be possible for someone to post a short example? I've been
struggling with formatting a form layout all day.

thank you,

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



Re: validationErrors in plugins

2008-08-18 Thread martinp

Sorry, ignore me. I hadn't used $this->User->read() before trying to
save and this was causing the problem.

On Aug 19, 12:47 am, martinp <[EMAIL PROTECTED]> wrote:
> Hi - Been staring at this for a few hours now and can't see what the
> problem is.. maybe someone can help?
>
> Somehow my validationErrors are getting lost on their way from the
> controller to the view.
>
> I have a simple form:
>                         echo $form->create('Users.User', array('url' => 
> $this->here))."\n";
>                         echo $form->input('email', array('error' => 
> array('email' => 'Must
> be a valid email address')))."\n";
>                         echo $form->input('password', array('value' => 
> false))."\n";
>                         echo $form->input('confirm_password', array('value' =>
> false))."\n";
>                         echo $form->end(__('Save', true))."\n";
>
> Which is part of my "Users" plugin. If an incorrect email address is
> entered the record doesn't save, but no validation error message is
> shown.
>
> I can print the $this->User->validationErrors array in my controller
> and see the validationError that's set in the model, but nothing
> appears in the view.
>
> If I pr($this->validationErrors) in the view I have an empty array.
>
> Is there something I should be aware of when using plugins and
> validation? Extensive searching of this group etc hasn't found
> anything.
>
> For clarity, I have the following in my controller:
>         var $name = 'Users';
>         var $uses = 'Users.User';
>
> And the following in my model:
>     var $name = 'Users.User';
>         var $useTable = 'users';
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: generateList / Set::combine help

2008-08-18 Thread Zoltan

That worked perfectly... that's it- Cake makes this stuff way too
easy :)

Thanks,
Zoltan

On Aug 18, 6:50 pm, AD7six <[EMAIL PROTECTED]> wrote:
> On Aug 19, 12:31 am, Zoltan <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi
>
> > I'm trying to figure out the syntax for creating an array in the
> > proper format for grouping by as the old generateList method did (but
> > using 1.2's find() instead)
>
> > This is the array I have:
> > Array
> > (
> >     [0] => Array
> >         (
> >             [ReviewTopic] => Array
> >                 (
> >                     [id] => 7
> >                     [name] => Linux
> >                     [review_category_id] => 'book'
> >                 )
>
> >         )
>
> >     [1] => Array
> >         (
> >             [ReviewTopic] => Array
> >                 (
> >                     [id] => 19
> >                     [name] => Software development
> >                     [review_category_id] => 'book'
> >                 )
>
> >         )...
>
> > ...and I'm trying to set it up so:
>
> > ['book'] => array ( 7 => 'Linux', 19 => 'software development' );
>
> > using the set::combine functions with something like ($reviewTopic has
> > the record in the above form):
>
> > $newList = Set::combine         (       $reviewTopic,
> >                 '{n}.ReviewTopic.review_category_id',
> >                 '{n}.ReviewTopic.id'
> >         );
>
> > Can anyone suggest something?
>
> find('list', array('fields' => array('ReviewTopic.id',
> 'ReviewTopic.name', 'ReviewCategory.id'), 'recursive' => 0));
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Acl and Auth slow page load

2008-08-18 Thread Marcus J. Ertl
Marcus J. Ertl schrieb:

Hi again!
> I'm afraid, this is poor application design on my side too. :-(
>   
OK, I took a look into this! It was bad design on my side! :-(

I've startet with more then 60 queries, taking about 30 seconds! :-(

After taking the check outside the loop, I'm down to 24 queries, taking
about 10 seconds.

Adding indexes to the acos- and aros-tables brought down the time for
this queries to about 2 seconds!

A closer look shows, it's allways the same query taking to long:

*23. Affected: 36 Num. rows: 36 Took: 502ms*
SELECT `Aco`.`id`, `Aco`.`parent_id`, `Aco`.`model`,
`Aco`.`foreign_key`, `Aco`.`alias` FROM `acos` AS `Aco` LEFT JOIN
`acos` AS `Aco0` ON (`Aco0`.`alias` = 'links') LEFT JOIN `acos` AS
`Aco1` ON (`Aco1`.`lft` > `Aco0`.`lft` AND `Aco1`.`rght` <
`Aco0`.`rght` AND `Aco1`.`alias` = 'mod_edit') WHERE ((`Aco`.`lft`
<= `Aco0`.`lft` AND `Aco`.`rght` >= `Aco0`.`rght`) OR (`Aco`.`lft`
<= `Aco1`.`lft` AND `Aco`.`rght` >= `Aco1`.`rght`)) ORDER BY
`Aco`.`lft` DESC



This is not perfekt, but I can life with this values. But it would be
nice, if I could get this querys down in time too!

Will be there some acl-caching as core feature in cakephp 1.2? Or have I
to do it by myself?

Thank you very much!

Bye
Marcus


smime.p7s
Description: S/MIME Cryptographic Signature


Field Naming Convention

2008-08-18 Thread kienpham2000

Hi all cake bakers,

I'm using the 1.2RC and I followed the field naming convention here to
get array of data for a field name:
http://book.cakephp.org/view/547/field-naming-convention

Here is my code to create input fields:
input('MyModel.myField.1');?>
input('MyModel.myField.2');?>

But when it displays, my label is 1 and 2 but not My Field. I have to
manually set the label like this:
input('MyModel.myField.1', array('label' => 'My Field 1'));?
>
input('MyModel.myField.2', array('label' => 'My Field 2);?>

Did I created the field wrong or do I just have to manually type in
the label? Also, in plain php, we can just use the two bracket at the
end [] and the posted data will automatically create the array for us,
can we do something like that with cake using the form helper?

Thanks all!
- Kien


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



Re: generateList / Set::combine help

2008-08-18 Thread AD7six



On Aug 19, 12:31 am, Zoltan <[EMAIL PROTECTED]> wrote:
> Hi
>
> I'm trying to figure out the syntax for creating an array in the
> proper format for grouping by as the old generateList method did (but
> using 1.2's find() instead)
>
> This is the array I have:
> Array
> (
>     [0] => Array
>         (
>             [ReviewTopic] => Array
>                 (
>                     [id] => 7
>                     [name] => Linux
>                     [review_category_id] => 'book'
>                 )
>
>         )
>
>     [1] => Array
>         (
>             [ReviewTopic] => Array
>                 (
>                     [id] => 19
>                     [name] => Software development
>                     [review_category_id] => 'book'
>                 )
>
>         )...
>
> ...and I'm trying to set it up so:
>
> ['book'] => array ( 7 => 'Linux', 19 => 'software development' );
>
> using the set::combine functions with something like ($reviewTopic has
> the record in the above form):
>
> $newList = Set::combine         (       $reviewTopic,
>                 '{n}.ReviewTopic.review_category_id',
>                 '{n}.ReviewTopic.id'
>         );
>
> Can anyone suggest something?

find('list', array('fields' => array('ReviewTopic.id',
'ReviewTopic.name', 'ReviewCategory.id'), 'recursive' => 0));
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Best practice: DB table data needed in a view helper?

2008-08-18 Thread francky06l

@Mark,

Kalt suggestion is goof for an element. You could also user an helper
and caching. The helper would check the cached file, if not there or
expired your helper can do a requestAction and cache the results for
future calls.
I use this quite a lot for fetching data for select for example (like
for a category list, not changing every 10 seconds, and avoiding
queries), and manually delete the cache when I update the tables..

hth

On Aug 19, 12:38 am, Kalt <[EMAIL PROTECTED]> wrote:
> Take a look at the "requestAction" method.
>
> And instead of a helper, I think you'd better use an element.
>
> On 19 août, 00:06, "Mark (Germany)" <[EMAIL PROTECTED]>
> wrote:
>
> > I have a helper which needs the "codecats" table data (20-40 rows)
> > everywhere where it is used.
> > i sure could ask for it in the controller:
> > ->list('all')..
> > and pass it the view
> > there i can again pass it to the helper
>
> > but is there
> > a) a way to automatically pass it from the controller to the helper
> > b) directly get the information into the helper (without having to
> > manually query the DB)
>
> > i have thought about using some caching or file-exporting (xml)
> > the helper could read out this file again.
> > but - what kind of backup would there be if the file gets lost somehow
> > (as it is in temp folder the max lifetime may be over some time)?
> > or is this a good practive anyway?
>
> > thats what is bothering me right now
> > as i do not know how to stick to the MVC pattern
>
> > especially because this helper is not bound to specific controllers
> > and may be used quite a lot.
> > so it would be really a huge load of code if i have to do it as
> > described above: controller -> view -> helper
>
> > thx
> > mark
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



validationErrors in plugins

2008-08-18 Thread martinp

Hi - Been staring at this for a few hours now and can't see what the
problem is.. maybe someone can help?

Somehow my validationErrors are getting lost on their way from the
controller to the view.

I have a simple form:
echo $form->create('Users.User', array('url' => 
$this->here))."\n";
echo $form->input('email', array('error' => 
array('email' => 'Must
be a valid email address')))."\n";
echo $form->input('password', array('value' => 
false))."\n";
echo $form->input('confirm_password', array('value' =>
false))."\n";
echo $form->end(__('Save', true))."\n";

Which is part of my "Users" plugin. If an incorrect email address is
entered the record doesn't save, but no validation error message is
shown.

I can print the $this->User->validationErrors array in my controller
and see the validationError that's set in the model, but nothing
appears in the view.

If I pr($this->validationErrors) in the view I have an empty array.

Is there something I should be aware of when using plugins and
validation? Extensive searching of this group etc hasn't found
anything.

For clarity, I have the following in my controller:
var $name = 'Users';
var $uses = 'Users.User';

And the following in my model:
var $name = 'Users.User';
var $useTable = 'users';
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Best practice: DB table data needed in a view helper?

2008-08-18 Thread Kalt

Take a look at the "requestAction" method.

And instead of a helper, I think you'd better use an element.

On 19 août, 00:06, "Mark (Germany)" <[EMAIL PROTECTED]>
wrote:
> I have a helper which needs the "codecats" table data (20-40 rows)
> everywhere where it is used.
> i sure could ask for it in the controller:
> ->list('all')..
> and pass it the view
> there i can again pass it to the helper
>
> but is there
> a) a way to automatically pass it from the controller to the helper
> b) directly get the information into the helper (without having to
> manually query the DB)
>
> i have thought about using some caching or file-exporting (xml)
> the helper could read out this file again.
> but - what kind of backup would there be if the file gets lost somehow
> (as it is in temp folder the max lifetime may be over some time)?
> or is this a good practive anyway?
>
> thats what is bothering me right now
> as i do not know how to stick to the MVC pattern
>
> especially because this helper is not bound to specific controllers
> and may be used quite a lot.
> so it would be really a huge load of code if i have to do it as
> described above: controller -> view -> helper
>
> thx
> mark
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Acl and Auth slow page load

2008-08-18 Thread Marcus J. Ertl
mark_story schrieb:

Hi Mark!
> Tiggr:  How many queries is ACL component doing. Normally for a single
> check it is ~6 db calls.  If you are doing more than one acl check per-
> page you should be caching the results, so you can use them over
> again.  But caching is not part of the core ACL component.
>   
I see 69 calls related to ACL! :-(

I'm afraid, this is poor application design on my side too. :-(

I go through a list of 10 entries (pagination, this is why they are max
10 entries per page.) On each entry I check for the rights to edit this
entry! Thinking about it, I think it's no problem to put this checks
outside the loop!

Talking about it makes me thinking about it! Sorry about asking silly
questions!

I try to optimize my views, and tell you, if it get's better!

Bye and thanks
Marcus


smime.p7s
Description: S/MIME Cryptographic Signature


Re: Bake and MySQL problems

2008-08-18 Thread [EMAIL PROTECTED]

php -m gives me the following :

[PHP Modules]
ctype
curl
date
dom
exif
filter
ftp
hash
iconv
json
ldap
libxml
mbstring
mysql
mysqli
odbc
openssl
pcre
PDO
pdo_sqlite
posix
Reflection
session
SimpleXML
sockets
SPL
SQLite
standard
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
xsl
zlib

[Zend Modules]

and php --ini gives me the following:

Configuration File (php.ini) Path: /etc
Loaded Configuration File: (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed:  (none)


I uncommented the mysql statements in the php.ini.default, but
received errors about php being unable to load dynamic libraries.


Thanks for your help.



On Aug 18, 5:31 pm, "Christian Winther" <[EMAIL PROTECTED]> wrote:
> Or do this in CLI:
>
> "php -m"  to get a list of loaded modules
> and
> "php --ini" to get a list of ini files loaded by CLI
>
> Those two should point you in the right direction
>
> -Original Message-
> From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Marcin 
> Domanski
> Sent: 18. august 2008 23:21
> To: cake-php@googlegroups.com
> Subject: Re: Bake and MySQL problems
>
> Hey,
> probably (99%) you PHP CLI doesnt have mysql extension loaded .  find
> the php.ini responisble for cli and uncomment the mysql extension
> lines.
> --
> Marcin Domanskihttp://kabturek.info
>
> On Mon, Aug 18, 2008 at 3:51 PM, [EMAIL PROTECTED]
> <[EMAIL PROTECTED]> wrote:
>
> > Hi everyone,
>
> > I am going through David Golding's new book "Beginning CakePHP" and
> > have found it extremely helpful up until the Bake section.
>
> > I have built a scaffolded blog, so I know that my DB connections are
> > correct.  And the paths to my app are correct in Terminal.  However,
> > when I go to bake my controller, I receive this messages from
> > Terminal:
>
> > Warning: mysql_connect(): Can't connect to local MySQL server through
> > socket '/var/mysql/mysql.sock' (2) in /Users/iZach/Sites/dev/blog/cake/
> > libs/model/datasources/dbo/dbo_mysql.php on line 117
>
> > Warning: mysql_select_db(): supplied argument is not a valid MySQL-
> > Link resource in /Users/iZach/Sites/dev/blog/cake/libs/model/
> > datasources/dbo/dbo_mysql.php on line 122
>
> > Warning: mysql_get_server_info(): supplied argument is not a valid
> > MySQL-Link resource in /Users/iZach/Sites/dev/blog/cake/libs/model/
> > datasources/dbo/dbo_mysql.php on line 130
>
> > Warning: mysql_query(): supplied argument is not a valid MySQL-Link
> > resource in /Users/iZach/Sites/dev/blog/cake/libs/model/datasources/
> > dbo/dbo_mysql.php on line 152
> > Error: Your database does not have any tables.
>
> > But my database is connected and does have tables!
>
> > I am using RC 1.2.x.x_17.08.2008
>
> > Thanks so much.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



generateList / Set::combine help

2008-08-18 Thread Zoltan

Hi

I'm trying to figure out the syntax for creating an array in the
proper format for grouping by as the old generateList method did (but
using 1.2's find() instead)

This is the array I have:
Array
(
[0] => Array
(
[ReviewTopic] => Array
(
[id] => 7
[name] => Linux
[review_category_id] => 'book'
)

)

[1] => Array
(
[ReviewTopic] => Array
(
[id] => 19
[name] => Software development
[review_category_id] => 'book'
)

)...

...and I'm trying to set it up so:

['book'] => array ( 7 => 'Linux', 19 => 'software development' );

using the set::combine functions with something like ($reviewTopic has
the record in the above form):

$newList = Set::combine (   $reviewTopic,
'{n}.ReviewTopic.review_category_id',
'{n}.ReviewTopic.id'
);

Can anyone suggest something?

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



Re: Printing labels with barcodes (PDF)

2008-08-18 Thread LunarDraco

I would take a look at using an rtf library. This will give you the
control you need over your layout and allow you to specify fonts.
You'll also need a Code 3 of 9 font.
Then you can specify your text and build all the barcodes in the
format of *12348* etc.

rtf class: http://www.phpclasses.org/browse/package/1805.html
If you need to provide a pdf of the document for a client that may not
have the font installed you could then use:
http://paggard.com/projects/doc.generator/
I'm sure there are some open source converters out there.

This is a task I'm going to need to be building soon myself, but I
have no current time line on this feature as of yet. However if you
get something working a follow up post would be awesome.

Morgan

On Aug 14, 10:11 pm, "Dr. Tarique Sani" <[EMAIL PROTECTED]> wrote:
> On Fri, Aug 15, 2008 at 4:46 AM, the_woodsman <[EMAIL PROTECTED]>wrote:
>
>
>
> > I've tried using
>
> >http://www.mribti.com/barcode/
>
> > the 3rd hit on a google search,  for php barcodes to insert into PDF.
> > It generates images, so that might scale better for you, but that'll
> > of course affect your file sizes.
>
> +1 for the above lib there are several more at phpclasses.org
>
> Yes, barcode on image is a much simpler option...
>
> Tarique
>
> --
> =
> Cheesecake-Photoblog:http://cheesecake-photoblog.org
> PHP for E-Biz:http://sanisoft.com
> =
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Best practice: DB table data needed in a view helper?

2008-08-18 Thread Mark (Germany)

I have a helper which needs the "codecats" table data (20-40 rows)
everywhere where it is used.
i sure could ask for it in the controller:
->list('all')..
and pass it the view
there i can again pass it to the helper

but is there
a) a way to automatically pass it from the controller to the helper
b) directly get the information into the helper (without having to
manually query the DB)

i have thought about using some caching or file-exporting (xml)
the helper could read out this file again.
but - what kind of backup would there be if the file gets lost somehow
(as it is in temp folder the max lifetime may be over some time)?
or is this a good practive anyway?

thats what is bothering me right now
as i do not know how to stick to the MVC pattern

especially because this helper is not bound to specific controllers
and may be used quite a lot.
so it would be really a huge load of code if i have to do it as
described above: controller -> view -> helper

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



Re: Specific Directories

2008-08-18 Thread Arak Tai'Roth

Hmmm, well, that definitely solved the problem much easier. Never
though of that. Thank you very much for your help.

On Aug 18, 3:23 pm, "Marcin Domanski" <[EMAIL PROTECTED]> wrote:
> 1.in production you document root should point to app/webroot.
> 2. if you have a directory in app/webroot cake wil show that directory
> first insted of trying to find a controller for it
> HTH,
> --
> Marcin Domanskihttp://kabturek.info
>
> On Mon, Aug 18, 2008 at 9:49 PM, Arak Tai'Roth <[EMAIL PROTECTED]> wrote:
>
> > I thought that might be the solution. I was looking around at how to
> > write RewriteRules in .htaccess, everything I can find seems to be a
> > more complicated problem then what mine is, and thus a more
> > complicated solution. Do you have any example code or somewhere I can
> > see example code in regards to this problem?
>
> > On Aug 18, 12:06 pm, Kalt <[EMAIL PROTECTED]> wrote:
> >> Simply add a rule to your www/.htaccess, so everything starting with
> >> portfolio/ is NOT redirected to index.php
>
> >> On 18 août, 19:44, "Arak Tai'Roth" <[EMAIL PROTECTED]> wrote:
>
> >> > So, I have this problem and wasn't even sure what to search for to
> >> > find a solution, so I thought I would ask here.
>
> >> > In my main directory, I have the normal cake folders app, cake, docs,
> >> > and vendors.
>
> >> > However, I also have a directory called portfolio. What I want is when
> >> > a user types inhttp://www.mysite.com/portfolio/*. I want it to take
> >> > him to whatever is stored in that folder, instead of applying Cake to
> >> > it and looking for controllers, models, etc
>
> >> > Is there anyway to do this, and if so how?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Selective field model validation

2008-08-18 Thread francky06l

Check carefully the meaning of "required" versus "notEmpty" (or '/\S
+/') in validation  ("required" makes the field mandatory -- but can
be empty -- every time single time you call validation, whether the
field is in a form or not).
Some usage of "on" => "create" might also help.

hth

On Aug 18, 9:55 pm, AD7six <[EMAIL PROTECTED]> wrote:
> On Aug 18, 9:47 pm, David Yell <[EMAIL PROTECTED]> wrote:
>
> > This was solved in #cakephp
> > By using $this->Model->validates($this->data['Model']['field']
>
> > So big thanks to penfold_99 for sorting this for me, thanks!
>
> That reminds me of the time someone "optimized" my code by commenting
> out all the code that did anything...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



RE: Bake and MySQL problems

2008-08-18 Thread Christian Winther

Or do this in CLI:

"php -m"  to get a list of loaded modules 
and
"php --ini" to get a list of ini files loaded by CLI 

Those two should point you in the right direction

-Original Message-
From: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Marcin 
Domanski
Sent: 18. august 2008 23:21
To: cake-php@googlegroups.com
Subject: Re: Bake and MySQL problems


Hey,
probably (99%) you PHP CLI doesnt have mysql extension loaded .  find
the php.ini responisble for cli and uncomment the mysql extension
lines.
--
Marcin Domanski
http://kabturek.info



On Mon, Aug 18, 2008 at 3:51 PM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>
> Hi everyone,
>
> I am going through David Golding's new book "Beginning CakePHP" and
> have found it extremely helpful up until the Bake section.
>
> I have built a scaffolded blog, so I know that my DB connections are
> correct.  And the paths to my app are correct in Terminal.  However,
> when I go to bake my controller, I receive this messages from
> Terminal:
>
>
> Warning: mysql_connect(): Can't connect to local MySQL server through
> socket '/var/mysql/mysql.sock' (2) in /Users/iZach/Sites/dev/blog/cake/
> libs/model/datasources/dbo/dbo_mysql.php on line 117
>
> Warning: mysql_select_db(): supplied argument is not a valid MySQL-
> Link resource in /Users/iZach/Sites/dev/blog/cake/libs/model/
> datasources/dbo/dbo_mysql.php on line 122
>
> Warning: mysql_get_server_info(): supplied argument is not a valid
> MySQL-Link resource in /Users/iZach/Sites/dev/blog/cake/libs/model/
> datasources/dbo/dbo_mysql.php on line 130
>
> Warning: mysql_query(): supplied argument is not a valid MySQL-Link
> resource in /Users/iZach/Sites/dev/blog/cake/libs/model/datasources/
> dbo/dbo_mysql.php on line 152
> Error: Your database does not have any tables.
>
>
>
>
> But my database is connected and does have tables!
>
> I am using RC 1.2.x.x_17.08.2008
>
>
>
>
> Thanks so much.
>
> >
>



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



Re: Specific Directories

2008-08-18 Thread Marcin Domanski
1.in production you document root should point to app/webroot.
2. if you have a directory in app/webroot cake wil show that directory
first insted of trying to find a controller for it
HTH,
--
Marcin Domanski
http://kabturek.info



On Mon, Aug 18, 2008 at 9:49 PM, Arak Tai'Roth <[EMAIL PROTECTED]> wrote:
>
> I thought that might be the solution. I was looking around at how to
> write RewriteRules in .htaccess, everything I can find seems to be a
> more complicated problem then what mine is, and thus a more
> complicated solution. Do you have any example code or somewhere I can
> see example code in regards to this problem?
>
> On Aug 18, 12:06 pm, Kalt <[EMAIL PROTECTED]> wrote:
>> Simply add a rule to your www/.htaccess, so everything starting with
>> portfolio/ is NOT redirected to index.php
>>
>> On 18 août, 19:44, "Arak Tai'Roth" <[EMAIL PROTECTED]> wrote:
>>
>> > So, I have this problem and wasn't even sure what to search for to
>> > find a solution, so I thought I would ask here.
>>
>> > In my main directory, I have the normal cake folders app, cake, docs,
>> > and vendors.
>>
>> > However, I also have a directory called portfolio. What I want is when
>> > a user types inhttp://www.mysite.com/portfolio/*. I want it to take
>> > him to whatever is stored in that folder, instead of applying Cake to
>> > it and looking for controllers, models, etc
>>
>> > Is there anyway to do this, and if so how?
> >
>

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



Re: Acl and Auth slow page load

2008-08-18 Thread francky06l

You might also index your aros/acos tables, according to the mode used
in Auth ...

On Aug 18, 10:51 pm, mark_story <[EMAIL PROTECTED]> wrote:
> Tiggr:  How many queries is ACL component doing. Normally for a single
> check it is ~6 db calls.  If you are doing more than one acl check per-
> page you should be caching the results, so you can use them over
> again.  But caching is not part of the core ACL component.
>
> -Mark
>
> On Aug 18, 3:12 am, Tiggr <[EMAIL PROTECTED]> wrote:
>
> > Hi!
>
> > > var $components = array('Acl', 'Auth', 'Email');
>
> > > The page load goes through the roof.
>
> > Just the same for me, but only with Acl! And it isn't slow all the
> > time, pages load fast when user isn't logged in, but after logging in,
> > all is getting worse! Loadtime goes up through the roof because of the
> > many sql-queries acl does! :-(
>
> > I'm going to implement some sort of caching, but that's no real
> > solution, only a work around!
>
> > Is there a way to reduce the amount of queries in acl?
>
> > Bye
> > Marcus
>
> > PS: It's my first page with cake...! You may have a look at the page
> > athttp://www.larp-welt.de, and at the code 
> > athttp://code.google.com/p/cakelinks/source/browse/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Bake and MySQL problems

2008-08-18 Thread Marcin Domanski

Hey,
probably (99%) you PHP CLI doesnt have mysql extension loaded .  find
the php.ini responisble for cli and uncomment the mysql extension
lines.
--
Marcin Domanski
http://kabturek.info



On Mon, Aug 18, 2008 at 3:51 PM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>
> Hi everyone,
>
> I am going through David Golding's new book "Beginning CakePHP" and
> have found it extremely helpful up until the Bake section.
>
> I have built a scaffolded blog, so I know that my DB connections are
> correct.  And the paths to my app are correct in Terminal.  However,
> when I go to bake my controller, I receive this messages from
> Terminal:
>
>
> Warning: mysql_connect(): Can't connect to local MySQL server through
> socket '/var/mysql/mysql.sock' (2) in /Users/iZach/Sites/dev/blog/cake/
> libs/model/datasources/dbo/dbo_mysql.php on line 117
>
> Warning: mysql_select_db(): supplied argument is not a valid MySQL-
> Link resource in /Users/iZach/Sites/dev/blog/cake/libs/model/
> datasources/dbo/dbo_mysql.php on line 122
>
> Warning: mysql_get_server_info(): supplied argument is not a valid
> MySQL-Link resource in /Users/iZach/Sites/dev/blog/cake/libs/model/
> datasources/dbo/dbo_mysql.php on line 130
>
> Warning: mysql_query(): supplied argument is not a valid MySQL-Link
> resource in /Users/iZach/Sites/dev/blog/cake/libs/model/datasources/
> dbo/dbo_mysql.php on line 152
> Error: Your database does not have any tables.
>
>
>
>
> But my database is connected and does have tables!
>
> I am using RC 1.2.x.x_17.08.2008
>
>
>
>
> Thanks so much.
>
> >
>

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



Re: Acl and Auth slow page load

2008-08-18 Thread mark_story

Tiggr:  How many queries is ACL component doing. Normally for a single
check it is ~6 db calls.  If you are doing more than one acl check per-
page you should be caching the results, so you can use them over
again.  But caching is not part of the core ACL component.

-Mark

On Aug 18, 3:12 am, Tiggr <[EMAIL PROTECTED]> wrote:
> Hi!
>
> > var $components = array('Acl', 'Auth', 'Email');
>
> > The page load goes through the roof.
>
> Just the same for me, but only with Acl! And it isn't slow all the
> time, pages load fast when user isn't logged in, but after logging in,
> all is getting worse! Loadtime goes up through the roof because of the
> many sql-queries acl does! :-(
>
> I'm going to implement some sort of caching, but that's no real
> solution, only a work around!
>
> Is there a way to reduce the amount of queries in acl?
>
> Bye
> Marcus
>
> PS: It's my first page with cake...! You may have a look at the page
> athttp://www.larp-welt.de, and at the code 
> athttp://code.google.com/p/cakelinks/source/browse/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: isUnique model validation 'on create' not working?

2008-08-18 Thread Zoltan

Problem turned out to be I had taken the 'id' field out of the
edit.ctp file.  Put it back in, and everything worked fine.

Zoltan

On Aug 18, 1:38 pm, haj <[EMAIL PROTECTED]> wrote:
> I know I'm not answering to the question but a field that needs to be
> unique generally hold the same requirement on an edit?
> For the real answer, it's working here. Sorry for not helping..
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Selective field model validation

2008-08-18 Thread AD7six



On Aug 18, 9:47 pm, David Yell <[EMAIL PROTECTED]> wrote:
> This was solved in #cakephp
> By using $this->Model->validates($this->data['Model']['field']
>
> So big thanks to penfold_99 for sorting this for me, thanks!

That reminds me of the time someone "optimized" my code by commenting
out all the code that did anything...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Specific Directories

2008-08-18 Thread Arak Tai'Roth

I thought that might be the solution. I was looking around at how to
write RewriteRules in .htaccess, everything I can find seems to be a
more complicated problem then what mine is, and thus a more
complicated solution. Do you have any example code or somewhere I can
see example code in regards to this problem?

On Aug 18, 12:06 pm, Kalt <[EMAIL PROTECTED]> wrote:
> Simply add a rule to your www/.htaccess, so everything starting with
> portfolio/ is NOT redirected to index.php
>
> On 18 août, 19:44, "Arak Tai'Roth" <[EMAIL PROTECTED]> wrote:
>
> > So, I have this problem and wasn't even sure what to search for to
> > find a solution, so I thought I would ask here.
>
> > In my main directory, I have the normal cake folders app, cake, docs,
> > and vendors.
>
> > However, I also have a directory called portfolio. What I want is when
> > a user types inhttp://www.mysite.com/portfolio/*. I want it to take
> > him to whatever is stored in that folder, instead of applying Cake to
> > it and looking for controllers, models, etc
>
> > Is there anyway to do this, and if so how?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Selective field model validation

2008-08-18 Thread David Yell

This was solved in #cakephp
By using $this->Model->validates($this->data['Model']['field']

So big thanks to penfold_99 for sorting this for me, thanks!

On Aug 18, 3:26 pm, David Yell <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I've been doing some work with my users model and I got to a stage
> where I was creating a method to change a users password to avoid the
> default edit screen from having a populated password and such. Either
> way I ended up with a change_password method and view, this works
> great.
>
> On this page I have two password fields which are checked using a
> custom match rule in my model btw. Then if they pass validation I copy
> one into the password field and save it. The validation is called
> using $this->User->validates() in the controller.  But I was trying to
> validate the password and my model was throwing all kinds of strange
> errors. When I finally dropped in a die(pr($this->User->invalidFields())); 
> into my controller it was showing that all the
>
> other fields, which were marked as required were also being validated.
>
> I got around it by adding the fields as hidden to the form and
> submitting it.
>
> The main question is, is there a way to pass any field list into
> validates or create a validateFields() which takes an array of fields
> to validate? Is this possible? My colleague tells me that I should
> really be creating a passwords model and such and then relating it to
> my User but this seems a little overkill.
>
> In a similar circumstance which I just arrived at again, I am
> forwarding a job to a friend via email and I would like to validate
> the email field against the model before sending the email. Again I
> can't validate just this one field without validating the whole model.
> Yet again, should I be creating a ForwardtoFriend model with no table
> and it's own controller to do this and then associate it with the
> Vacancy?
>
> It seems to me that it might be a bit of a hacky shortcut to be able
> to specify which model fields you want to validate, but one that would
> be super handy, or am I missing the point here? (which is entirely
> possible ;p)
>
> Ta,
> Dave
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: CakePHP + Flash

2008-08-18 Thread Pettor

Ohh thanks for the tips!

I will test them tomorrow. The way of fetching variables through the
 tag looks nice!

Thanks! I reply if i get into trouble :).
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: keeping model cache might improve performace

2008-08-18 Thread Gwoo

@stefanski
You did not define all the required settings so the config was not
created. Specifically, you must specify an "engine"
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Find with custom GROUP BY and ORDER BY

2008-08-18 Thread Pixelastic

You're right, that was clearly the way I should have handle that.
Works like a charm.

Thanks a lot

On 18 août, 15:53, Kalt <[EMAIL PROTECTED]> wrote:
> I think you are doing it the wrong way : you don't want to order your
> buildings by flat price, you want to order them by the minimum flat
> price. Here is my solution :
>
> // controllers/buildings_controller.php
> function index() {
>   // Trick to have LEFT JOIN in the query
>   $this->Building->unbindModel(array('hasMany' => array('Flat')));
>   $this->Building->bindModel(array('hasOne' => array('Flat')));
>
>   $data = $this->Building->find('all', array(
>     'fields' => array('Building.id', 'MIN(Flat.price) AS
> flat_min_price'),
>     'group' => 'Building.id',
>     'order' => 'flat_min_price ASC'
>   ));
>
> }
>
> Pixelastic a écrit :
>
> > Hello,
>
> > I'm trying to use on a find query the 'group' and 'order' parameters,
> > but the two seems not to work well together (or at least not the way I
> > would).
>
> > I have a simple structure like this :
> > Model 'Building' (id, name)
> > Model 'Flat' (id, building_id, price)
> > (and Flat belongsTo Building, obviously)
>
> > Each Building has more or less 60 flats and I would like to display on
> > BuildingController::index the list of all Buildings, ordered by flat
> > price. That means that the building with the cheaper flat will be
> > displayed first, and then the building with the second cheaper flat
> > and so on.
>
> > I tried a simple query like that :
> > $this->Flat->find(
> >                    'all',
> >                    array(
> >                            'order' => array('Flat.price' => 'ASC'),
> >                            'group' => 'Flat.building_id'
> >                    )
> >            );
> > But the GROUP BY clause is executed first, before the ORDER BY, and
> > picks results in an impredictable way. It's true that my results
> > (Flats) are ordered by price ASC, but they are not the cheaper of each
> > Building, they appear to be picked from my database in the order that
> > I added them.
>
> > I used to dealt with this problem in good old SQL by doing a query
> > like :
> > SELECT Flat.*
> > FROM (SELECT * FROM flats ORDER BY price ASC) AS Flat
> > GROUP BY Flat.building_id
> > ORDER BY Flat.price ASC
>
> > But I don't find the way to translate that query in the way the
> > Model::find() expect it (I would love to keep using the find() method
> > without custom queries in order to use beforeFind and afterFind).
>
> > Is there a way to tell the Model::find() method what to use for FROM ?
> > Or maybe someone knows a better way to achieve what I'm trying to do ?
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Specific Directories

2008-08-18 Thread Kalt

Simply add a rule to your www/.htaccess, so everything starting with
portfolio/ is NOT redirected to index.php

On 18 août, 19:44, "Arak Tai'Roth" <[EMAIL PROTECTED]> wrote:
> So, I have this problem and wasn't even sure what to search for to
> find a solution, so I thought I would ask here.
>
> In my main directory, I have the normal cake folders app, cake, docs,
> and vendors.
>
> However, I also have a directory called portfolio. What I want is when
> a user types inhttp://www.mysite.com/portfolio/*. I want it to take
> him to whatever is stored in that folder, instead of applying Cake to
> it and looking for controllers, models, etc
>
> Is there anyway to do this, and if so how?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: License issues

2008-08-18 Thread Werner Petry Moraes

Hey,

http://www.opensource.org/licenses/mit-license.php

...
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
...

That means yes, you can.

> Cakephp is released under MIT lincense. Can we use cakephp to develop
> commercial applications or only those applications that should be
> released under an MIT license or an opensource?
> Thanks a lot for ur guidance.

--
Werner Petry Moraes
[EMAIL PROTECTED]

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



Specific Directories

2008-08-18 Thread Arak Tai'Roth

So, I have this problem and wasn't even sure what to search for to
find a solution, so I thought I would ask here.

In my main directory, I have the normal cake folders app, cake, docs,
and vendors.

However, I also have a directory called portfolio. What I want is when
a user types in http://www.mysite.com/portfolio/*. I want it to take
him to whatever is stored in that folder, instead of applying Cake to
it and looking for controllers, models, etc

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



Re: License issues

2008-08-18 Thread Chris Hartjes

On Mon, Aug 18, 2008 at 1:30 PM, bigboss0101 <[EMAIL PROTECTED]> wrote:
>
> Hi friends,
> Cakephp is released under MIT lincense. Can we use cakephp to develop
> commercial applications or only those applications that should be
> released under an MIT license or an opensource?
> Thanks a lot for ur guidance.

I am not an intellectual property lawyer, but the answer to your
question is "Yes, you can use CakePHP to develop commercial
applications".

-- 
Chris Hartjes
Motto for 2008: "Moving from herding elephants to handling snakes..."
@TheKeyBoard: http://www.littlehart.net/atthekeyboard

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



License issues

2008-08-18 Thread bigboss0101

Hi friends,
Cakephp is released under MIT lincense. Can we use cakephp to develop
commercial applications or only those applications that should be
released under an MIT license or an opensource?
Thanks a lot for ur guidance.

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



Re: isUnique model validation 'on create' not working?

2008-08-18 Thread haj

I know I'm not answering to the question but a field that needs to be
unique generally hold the same requirement on an edit?
For the real answer, it's working here. Sorry for not helping..
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Selective field model validation

2008-08-18 Thread teknoid

I would suggest to carefully read the manual, where it talks about
data validation ;)

On Aug 18, 10:26 am, David Yell <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I've been doing some work with my users model and I got to a stage
> where I was creating a method to change a users password to avoid the
> default edit screen from having a populated password and such. Either
> way I ended up with a change_password method and view, this works
> great.
>
> On this page I have two password fields which are checked using a
> custom match rule in my model btw. Then if they pass validation I copy
> one into the password field and save it. The validation is called
> using $this->User->validates() in the controller.  But I was trying to
> validate the password and my model was throwing all kinds of strange
> errors. When I finally dropped in a die(pr($this->User->invalidFields())); 
> into my controller it was showing that all the
>
> other fields, which were marked as required were also being validated.
>
> I got around it by adding the fields as hidden to the form and
> submitting it.
>
> The main question is, is there a way to pass any field list into
> validates or create a validateFields() which takes an array of fields
> to validate? Is this possible? My colleague tells me that I should
> really be creating a passwords model and such and then relating it to
> my User but this seems a little overkill.
>
> In a similar circumstance which I just arrived at again, I am
> forwarding a job to a friend via email and I would like to validate
> the email field against the model before sending the email. Again I
> can't validate just this one field without validating the whole model.
> Yet again, should I be creating a ForwardtoFriend model with no table
> and it's own controller to do this and then associate it with the
> Vacancy?
>
> It seems to me that it might be a bit of a hacky shortcut to be able
> to specify which model fields you want to validate, but one that would
> be super handy, or am I missing the point here? (which is entirely
> possible ;p)
>
> Ta,
> Dave
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



isUnique model validation 'on create' not working?

2008-08-18 Thread Zoltan

In my model I'm doing something like:

var $validate = array(
'slug' => array('rule' => 'isUnique', 'on' => 'create', 
'message' =>
'This title slug has already been taken.'),
'venue_type_id' => array('numeric'),...

Creating a new record works fine.
Now the problem is it is doing the validation again when I edit the
record and save. It does the validation which of course fails (there
is 1 row with this same slug- the record i just edited)

What am I missing?

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



Re: CakePHP + Flash

2008-08-18 Thread Gwoo

using $html->url() for images/js/css will give you the wrong path if
you are not using mod_rewrite. For anything in the webroot, you should
use $html->webroot();
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: CakePHP + Flash

2008-08-18 Thread Adam Royle

1. Use cakephp to do this dirty work!
2. Use $html->url() to create your urls... it will create true
absolute urls, even if your cake app is a few levels deep.

eg.

use this as your controller/action path to send to flash

echo $html->url('/images/getImagesForFlash/');

and then in your getImagesForFlash view, using something like this:

&myimg=url('/files/images/myimgname.jpg') ?>

Obviously this is very rough since I don't know what models and output
format you're using, etc, but should give you an idea.

Cheers,
Adam

On Aug 18, 9:49 pm, Pettor <[EMAIL PROTECTED]> wrote:
> Hi, i have a strange problem with a Flash script and CakePHP.
>
> The Flash load images from paths that the database keeps. Because i
> have no clue how to make Flash work togheter with the CakePHP
> framework i wrote a simple read.php file that just connects to the
> database, grabs the paths and prints them. The Flash file use the
> command :"loadVariables("read.php", target_mc);" to fetch the paths
> thats been written by the read.php file into the variable target_mc.
> The read.php file is put in the same folder as the Flash file to make
> it work (the folder is webroot/flash/).
>
> However if i run the Flash file (.swf) by opening it from it's folder
> in webroot/flash/ it works fine. But now i started using CakePHP and
> all this webroot stuff is happening. So when i open the index.php,
> with the flash file attached to it, it doesn't load from the read.php
> because it can't find it. If i in the Flash file use an absolute path
> in the command loadVariables it works fine. The problem is that by
> doing this i have to know the path system on the server the file will
> finally be put on and i can't know that. So i must use a relative path
> and just can't get it to work.
>
> Any tips? Thanks for any help!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Selective field model validation

2008-08-18 Thread David Yell

Hi,

I've been doing some work with my users model and I got to a stage
where I was creating a method to change a users password to avoid the
default edit screen from having a populated password and such. Either
way I ended up with a change_password method and view, this works
great.

On this page I have two password fields which are checked using a
custom match rule in my model btw. Then if they pass validation I copy
one into the password field and save it. The validation is called
using $this->User->validates() in the controller.  But I was trying to
validate the password and my model was throwing all kinds of strange
errors. When I finally dropped in a die(pr($this->User-
>invalidFields())); into my controller it was showing that all the
other fields, which were marked as required were also being validated.

I got around it by adding the fields as hidden to the form and
submitting it.

The main question is, is there a way to pass any field list into
validates or create a validateFields() which takes an array of fields
to validate? Is this possible? My colleague tells me that I should
really be creating a passwords model and such and then relating it to
my User but this seems a little overkill.

In a similar circumstance which I just arrived at again, I am
forwarding a job to a friend via email and I would like to validate
the email field against the model before sending the email. Again I
can't validate just this one field without validating the whole model.
Yet again, should I be creating a ForwardtoFriend model with no table
and it's own controller to do this and then associate it with the
Vacancy?

It seems to me that it might be a bit of a hacky shortcut to be able
to specify which model fields you want to validate, but one that would
be super handy, or am I missing the point here? (which is entirely
possible ;p)

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



Bake and MySQL problems

2008-08-18 Thread [EMAIL PROTECTED]

Hi everyone,

I am going through David Golding's new book "Beginning CakePHP" and
have found it extremely helpful up until the Bake section.

I have built a scaffolded blog, so I know that my DB connections are
correct.  And the paths to my app are correct in Terminal.  However,
when I go to bake my controller, I receive this messages from
Terminal:


Warning: mysql_connect(): Can't connect to local MySQL server through
socket '/var/mysql/mysql.sock' (2) in /Users/iZach/Sites/dev/blog/cake/
libs/model/datasources/dbo/dbo_mysql.php on line 117

Warning: mysql_select_db(): supplied argument is not a valid MySQL-
Link resource in /Users/iZach/Sites/dev/blog/cake/libs/model/
datasources/dbo/dbo_mysql.php on line 122

Warning: mysql_get_server_info(): supplied argument is not a valid
MySQL-Link resource in /Users/iZach/Sites/dev/blog/cake/libs/model/
datasources/dbo/dbo_mysql.php on line 130

Warning: mysql_query(): supplied argument is not a valid MySQL-Link
resource in /Users/iZach/Sites/dev/blog/cake/libs/model/datasources/
dbo/dbo_mysql.php on line 152
Error: Your database does not have any tables.




But my database is connected and does have tables!

I am using RC 1.2.x.x_17.08.2008




Thanks so much.

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



Re: Find with custom GROUP BY and ORDER BY

2008-08-18 Thread Kalt

I think you are doing it the wrong way : you don't want to order your
buildings by flat price, you want to order them by the minimum flat
price. Here is my solution :

// controllers/buildings_controller.php
function index() {
  // Trick to have LEFT JOIN in the query
  $this->Building->unbindModel(array('hasMany' => array('Flat')));
  $this->Building->bindModel(array('hasOne' => array('Flat')));

  $data = $this->Building->find('all', array(
'fields' => array('Building.id', 'MIN(Flat.price) AS
flat_min_price'),
'group' => 'Building.id',
'order' => 'flat_min_price ASC'
  ));
}

Pixelastic a écrit :
> Hello,
>
> I'm trying to use on a find query the 'group' and 'order' parameters,
> but the two seems not to work well together (or at least not the way I
> would).
>
> I have a simple structure like this :
> Model 'Building' (id, name)
> Model 'Flat' (id, building_id, price)
> (and Flat belongsTo Building, obviously)
>
> Each Building has more or less 60 flats and I would like to display on
> BuildingController::index the list of all Buildings, ordered by flat
> price. That means that the building with the cheaper flat will be
> displayed first, and then the building with the second cheaper flat
> and so on.
>
> I tried a simple query like that :
> $this->Flat->find(
>   'all',
>   array(
>   'order' => array('Flat.price' => 'ASC'),
>   'group' => 'Flat.building_id'
>   )
>   );
> But the GROUP BY clause is executed first, before the ORDER BY, and
> picks results in an impredictable way. It's true that my results
> (Flats) are ordered by price ASC, but they are not the cheaper of each
> Building, they appear to be picked from my database in the order that
> I added them.
>
> I used to dealt with this problem in good old SQL by doing a query
> like :
> SELECT Flat.*
> FROM (SELECT * FROM flats ORDER BY price ASC) AS Flat
> GROUP BY Flat.building_id
> ORDER BY Flat.price ASC
>
> But I don't find the way to translate that query in the way the
> Model::find() expect it (I would love to keep using the find() method
> without custom queries in order to use beforeFind and afterFind).
>
> Is there a way to tell the Model::find() method what to use for FROM ?
> Or maybe someone knows a better way to achieve what I'm trying to do ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Password field automagically fills up to 40 characters or so !!

2008-08-18 Thread mark_story

Jeremy,

You shouldn't wrap entire form->input() calls in __() as you will have
to translate all the HTML as well, which can lead to nightmare town
quickly.  Better would be to just wrap the label field in __() so you
only need to translate the label string.

$form->input('User.password', array('size'=>20, 'label' =>
__('Password', true)));

-Mark

On Aug 17, 10:47 am, Jeremy Spouken <[EMAIL PROTECTED]> wrote:
> Yeah It happened to me.
>
> You should:
> __($form->input('User.password', array('size' => '20', 'label' =>
> 'Password', 'value' => '')));
>
> See the password value set to ''
>
> On Aug 17, 2:24 am, Malcolm Krugger <[EMAIL PROTECTED]>
> wrote:
>
> > Hello  Everyone
>
> > I'm using cakephp 1.2 RC2 version and cakephp rocks !!
>
> > For password field Im using validation as
>
> > 'password' => array(
>
> > 'minlength' => array(
> > 'rule' => array('minLength', '8'),
> > 'message' => 'Minimum length of 8 characters'
> > ),
> > 'maxlength' => array(
> > 'rule' => array('maxLength', '12'),
> > 'message' => 'Maximum length of 12 characters'
> > ),
>
> > ),
>
> > and it works perfect i.e if anyone enters less than 8 characters or
> > more than 12 characters in the password field they get the appropriate
> > error messages
>
> > So far so good !
>
> > The trouble began when I started using Auth component
>
> > Now the moment I enable the auth component what happens is this.. when
> > I enter a password even for say 3 characters and press submit the next
> > page shows an error  Maximum length of 12 characters even though I
> > entered just 3 characters..
>
> > Also I notice the password field getting filled up with about 40
> > characters or so automatically.. WHen I disable Auth component
> > everything returns to normal
>
> > YOu may ask why I need the AUth component I need it because I am
> > trying to compare passwords entered by the user in their form using
> > $this->Auth->password function...
>
> > On a completely different note
>
> > How do I access  this Auth->password function from a model.. since it
> > says $AUTH is not a recognized function .. ?
>
> > Malcom
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: keeping model cache might improve performace

2008-08-18 Thread NOSLOW

I've been digging into caching issues lately as I've seen a terrible
slow down recently. My problem was that I broke the file & dir caching
on my Windows machine by incorrectly loading a vendor file from
bootstrap.php. So even when debug = 0, it was still rebuilding the
cake_core_dir_map & cake_core_file_map files in the cache/persistent
folder. When that happens, every request forces Cake re-parse the
entire Cake core directory structure, *including* the fairly large /
tests folder, which I've seen take over 1 second on my slow IDE disk.

Anyways, I fixed my problem that I caused in bootstrap.php so now
caching is working fully as expected. I also moved the /tests and /
console directories out of the core when I don't need them so that
cake_core_dir_map & cake_core_file_map files rebuild much faster now
when debug > 0. That's a nice little performance boost I discovered
while tracking down my other issue. ;) I opened some tickets related
to these discoveries:

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



Re: Setting the database definition based on session values

2008-08-18 Thread Bruce

OK, I have tried things out on a very simple app, and have the
database switching working from a constructor in app_model. But I am
back to my initial problem of needing a way to direct the logic from
the controller somehow.

What I am intending to do is to access a family of controllers through
a central controller, setting the initial config values based on the
initial path. I have that part working fine between controllers, but
the behavior I don't seem to be able to read Session values or I
assume Configure values. I assume that this is because controllers are
processed after the AppModel code. Is there any way other than
Sessions and Configure to carry values to subsequent pages?

So in app_model, I have a constructor as follows:

 function __construct($id = false, $table = null, $ds = null) {
parent::__construct();
$this->useDbConfig = 'dbname';
 }

I want to be able to use some sort of variable value, based on logic
in an upstream page, in place of 'dbname'. If I was doing this in the
controller, I would use a session variable or a configuration value.
Maybe I should do the DbConfig thing in the controller, but that would
seem to me to be a kludge of the MVC approach.

On Aug 14, 10:53 pm, "Dardo Sordi Bogado" <[EMAIL PROTECTED]>
wrote:
> When overriding a model constructor, ie __construct() you have to
> respect the parent constructor signature (take the same parameter
> count) and call parent::__construct() with the given/custom parameters
> that the parent constructor is expecting.
>
> Also, showing the errors you get would help us help you.
>
> For further reference, read the Model::__construct() function 
> here:http://api.cakephp.org/1.2/libs_2model_2model_8php-source.html#l00314
>
> HTH,
> - Dardo Sordi.
>
> On Thu, Aug 14, 2008 at 8:31 AM, Bruce <[EMAIL PROTECTED]> wrote:
>
> > I am working on a somewhat complex application that involves multiple
> > models. If everything works out, there will be multiple instances of
> > the application for different clients, and my current intention is to
> > separate each instance into a separate database.
>
> > I am very much a self taught programmer, with no PHP training, so I
> > occasionally find it hard to follow some of the documentation where
> > background PHP knowledge is assumed.
>
> > I got things working fairly well at first, using some code in the
> > database configuration to set the database definition based on the
> > url. However that is only satisfactory for a single model. I am now
> > looking at alternative ways to set the database definition, possibly
> > from the model. I will access the application throgh a single entry
> > point, which will set Session variables based on the url. Other
> > controllers will then be called from that model and use the session
> > data and config variables to set up the varoius instances.
>
> > I found some references to using __construct(), but when I add an __
> > construct function in app_model.php I get errors.
>
> > Before I head further down this track, does anyone know if I can see
> > Session values from within a construct function in app_model? This is
> > fundamental to my planned approach. I also need to be sure that I can
> > sitch the default database from this construct function.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Find with custom GROUP BY and ORDER BY

2008-08-18 Thread Pixelastic

Hello,

I'm trying to use on a find query the 'group' and 'order' parameters,
but the two seems not to work well together (or at least not the way I
would).

I have a simple structure like this :
Model 'Building' (id, name)
Model 'Flat' (id, building_id, price)
(and Flat belongsTo Building, obviously)

Each Building has more or less 60 flats and I would like to display on
BuildingController::index the list of all Buildings, ordered by flat
price. That means that the building with the cheaper flat will be
displayed first, and then the building with the second cheaper flat
and so on.

I tried a simple query like that :
$this->Flat->find(
'all',
array(
'order' => array('Flat.price' => 'ASC'),
'group' => 'Flat.building_id'
)
);
But the GROUP BY clause is executed first, before the ORDER BY, and
picks results in an impredictable way. It's true that my results
(Flats) are ordered by price ASC, but they are not the cheaper of each
Building, they appear to be picked from my database in the order that
I added them.

I used to dealt with this problem in good old SQL by doing a query
like :
SELECT Flat.*
FROM (SELECT * FROM flats ORDER BY price ASC) AS Flat
GROUP BY Flat.building_id
ORDER BY Flat.price ASC

But I don't find the way to translate that query in the way the
Model::find() expect it (I would love to keep using the find() method
without custom queries in order to use beforeFind and afterFind).

Is there a way to tell the Model::find() method what to use for FROM ?
Or maybe someone knows a better way to achieve what I'm trying to do ?

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



Re: 2 column layout for $form->input() ?

2008-08-18 Thread Jonathan Snook

Options.
1. Each input is invariably encased in a DIV. Set a width to half that
of the container, and then float:left.
2. Put half the inputs in one DIV and the other half in another DIV.
Float the DIVs.
3. Create a table with two columns, put half the inputs in one cell
and half the inputs in another cell. Don't float.

I'd go with #1 or #2 depending on what your needs are and how critical
it is that the form be filled in a specific order. (ie: left to right,
top to bottom vs top to bottom, left to right)

-Jonathan

On Mon, Aug 18, 2008 at 8:20 AM, Malcolm Krugger
<[EMAIL PROTECTED]> wrote:
>
> Whenever I user $form->input in templates invariably it outputs one
> below the other
>
> How do I make a 2 column form using $form->input tags ?
>
> Malcolm

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



Re: CakePHP + Flash

2008-08-18 Thread clemos

Hi Pettor

It won't actually solve your particular problem (probably due to
security issues in Flash ?), but...
You should definitely pass the cake path variables to Flash through
HTML/Javascript. For example (in your  tag):

(it may depend on the way you embed your Flash app, ie swfobject has a
method addVariable("webroot","webroot ?>"); )
Like this, you have your paths variables set in your flash app
(_root.webroot and _root.base, probably), without loading anything.

Your way is kind of "dirty", IMHO.

Hope it helps...

+++
Clément

On Mon, Aug 18, 2008 at 1:49 PM, Pettor <[EMAIL PROTECTED]> wrote:
>
> Hi, i have a strange problem with a Flash script and CakePHP.
>
> The Flash load images from paths that the database keeps. Because i
> have no clue how to make Flash work togheter with the CakePHP
> framework i wrote a simple read.php file that just connects to the
> database, grabs the paths and prints them. The Flash file use the
> command :"loadVariables("read.php", target_mc);" to fetch the paths
> thats been written by the read.php file into the variable target_mc.
> The read.php file is put in the same folder as the Flash file to make
> it work (the folder is webroot/flash/).
>
> However if i run the Flash file (.swf) by opening it from it's folder
> in webroot/flash/ it works fine. But now i started using CakePHP and
> all this webroot stuff is happening. So when i open the index.php,
> with the flash file attached to it, it doesn't load from the read.php
> because it can't find it. If i in the Flash file use an absolute path
> in the command loadVariables it works fine. The problem is that by
> doing this i have to know the path system on the server the file will
> finally be put on and i can't know that. So i must use a relative path
> and just can't get it to work.
>
> Any tips? Thanks for any help!
>
> >
>

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



Re: Help with Model:find()

2008-08-18 Thread Kalt

Of course your solution is better and this is what I do too. I just
wanted to show Lauren how to do with her own setup.

On 18 août, 14:43, "Jon Bennett" <[EMAIL PROTECTED]> wrote:
> Hi Kalt,
>
> > @jon : the "unpaid" status should not be in the Payments but in the
> > Purchases
>
> ahh, yes - she wants all Purchases that have no payments made - I was
> really just trying to illustrate how containable can be used instead
> of the old hasOne/belongsTo hack.
>
> a far easier solution to the problem would be to store an interger for
> the status, you could assign things like so:
>
> 0 - unpaid/unprocessed
> 1 - paid/processed
> 2 - dispatched
> 3 - refunded
>
> no need to tunnel through any related tables, or make any
> calculations. I would have thought going about things would greatly
> reduce the number of queries/post processing required when outputting
> a list of orders as well.
>
> hth
>
> jon
>
> --
>
> jon bennett
> w:http://www.jben.net/
> iChat (AIM): jbendotnet Skype: jon-bennett
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Difference between read and find

2008-08-18 Thread clemos

Hi

Just look at the source :
http://api.cakephp.org/libs_2model_2model_8php-source.html#l00949

Model::read is only a wrapper for Model::find, which, as Dardo said,
and as mentionned in the API
(http://api.cakephp.org/class_model.html), populates Model::$data...
("find" doesn't do that)
It's just a quick helper method.

+++
Clément

On Sun, Aug 17, 2008 at 3:03 PM, haj <[EMAIL PROTECTED]> wrote:
>
>
>
> On Aug 15, 2:15 pm, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote:
>> > What's the difference between these two query methods? Should find and
>> > findAll be working?
>>
>> Use Model::read() when you have the ID, ie you know the record you are
>> referring to. Also read() will populate the Model::$data in a way
>> suitable for Model::save(),
>
> Doesn't find() do the same thing? findById() for instance isn't
> actually find(), is it? I can't see the benefit of differentiating
> yet.. Some elaboration appreciated..
> >
>

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



Re: Help with Model:find()

2008-08-18 Thread Jon Bennett

Hi Kalt,

> @jon : the "unpaid" status should not be in the Payments but in the
> Purchases

ahh, yes - she wants all Purchases that have no payments made - I was
really just trying to illustrate how containable can be used instead
of the old hasOne/belongsTo hack.

a far easier solution to the problem would be to store an interger for
the status, you could assign things like so:

0 - unpaid/unprocessed
1 - paid/processed
2 - dispatched
3 - refunded

no need to tunnel through any related tables, or make any
calculations. I would have thought going about things would greatly
reduce the number of queries/post processing required when outputting
a list of orders as well.

hth

jon



-- 

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

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



parameter 0 in requestAction do not work

2008-08-18 Thread Klaus Schwarzkopf

Hi,

i use the requestAction funktion with a parameter. The value of the
parameter is 0.

My cake version is 1.2.0.7296 RC2.

Controller:

$action='/repairs/getData/0';

$this->set('repairs', $this->requestAction($action));



I get this error:



Warning (2): Missing argument 1 for RepairsController::getData(), called
in /var/www/auftragnew/cake/cake/libs/object.php on line 115 and defined
[APP/controllers/repairs_controller.php, line 22]

Code



function getData($id)

RepairsController::getData() - APP/controllers/repairs_controller.php,
line 22
Object::dispatchMethod() - CORE/cake/libs/object.php, line 115
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 261
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 234
Object::requestAction() - CORE/cake/libs/object.php, line 99
OrdersController::view() - APP/controllers/orders_controller.php, line 652
Object::dispatchMethod() - CORE/cake/libs/object.php, line 117
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 261
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 234
[main] - APP/webroot/index.php, line 90


This function call does not work, too.


$this->requestAction(array('controller'=>'repairs', 'action'=>'getData',
0));


Thanks

Klaus



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



CakePHP + Flash

2008-08-18 Thread Pettor

Hi, i have a strange problem with a Flash script and CakePHP.

The Flash load images from paths that the database keeps. Because i
have no clue how to make Flash work togheter with the CakePHP
framework i wrote a simple read.php file that just connects to the
database, grabs the paths and prints them. The Flash file use the
command :"loadVariables("read.php", target_mc);" to fetch the paths
thats been written by the read.php file into the variable target_mc.
The read.php file is put in the same folder as the Flash file to make
it work (the folder is webroot/flash/).

However if i run the Flash file (.swf) by opening it from it's folder
in webroot/flash/ it works fine. But now i started using CakePHP and
all this webroot stuff is happening. So when i open the index.php,
with the flash file attached to it, it doesn't load from the read.php
because it can't find it. If i in the Flash file use an absolute path
in the command loadVariables it works fine. The problem is that by
doing this i have to know the path system on the server the file will
finally be put on and i can't know that. So i must use a relative path
and just can't get it to work.

Any tips? Thanks for any help!

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



Re: validation doen't work

2008-08-18 Thread clemos

Hi

On Mon, Aug 18, 2008 at 3:51 AM, skilled_dreamer <[EMAIL PROTECTED]> wrote:

>'rule'=> array('minLenght', 3),

I guess it should be minLength...

+
Clément

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



Re: Help with Model:find()

2008-08-18 Thread Kalt

@jon : the "unpaid" status should not be in the Payments but in the
Purchases

On 18 août, 14:03, "Jon Bennett" <[EMAIL PROTECTED]> wrote:
> Hi Lauren,
>
> providing you're using 1.2, a less hacky way would be to use the
> Containable behaviour.
>
> $this->Purchase->Behaviors->attach('Containable');
>
> $results = $this->Purchase->find('all', array(
>         'conditions'=>array('Purchase.account_id' => $account_id,
> 'Payment.id' => null),
>         'contain'=>array(
>                 'Payment'=>array('conditions'=>array(
>                         'Payment.status'=>'unpaid'
>         )))
> ));
>
> http://book.cakephp.org/view/474/containable
>
> hth
>
> jon
>
> --
>
> jon bennett
> w:http://www.jben.net/
> iChat (AIM): jbendotnet Skype: jon-bennett
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



2 column layout for $form->input() ?

2008-08-18 Thread Malcolm Krugger

Whenever I user $form->input in templates invariably it outputs one
below the other

How do I make a 2 column form using $form->input tags ?

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



Re: Help with Model:find()

2008-08-18 Thread Jon Bennett

Hi Lauren,

providing you're using 1.2, a less hacky way would be to use the
Containable behaviour.

$this->Purchase->Behaviors->attach('Containable');

$results = $this->Purchase->find('all', array(
'conditions'=>array('Purchase.account_id' => $account_id,
'Payment.id' => null),
'contain'=>array(
'Payment'=>array('conditions'=>array(
'Payment.status'=>'unpaid'
)))
));

http://book.cakephp.org/view/474/containable

hth

jon


-- 

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

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



ibm tutorial #2 product addition

2008-08-18 Thread fourcs

Can't get IBM tut#2 to restrict product addition to logged-in users.
This is the products_controller:

function add() {if (!empty($this->data)) {

  $this->Product->create();
  if ($this->Product->save($this->data)) {
  $dealer = $this->Product->Dealer->read(null,
   $this->data['Product']['dealer_id']);
  $parent = $this->Acl->Aco->findByAlias($dealer
['Dealer']['title']);
  $this->Acl->Aco->create(array(
   'alias' => $this->Product->id.'-'.$this->data
['Product']['title'],
   'model' => 'Product',
   'foreign_key' => $this->Product->id,
   'parent_id' => $parent['Aco']['id'])
);

This is the user login view:



Please log in.
create('User',
array('action' => 'login')); ?>

input('username');
echo $form->input('password');
?>

end('Login');?>
link('Register',
array('action' => 'register'));?>

  The use login view works, but the products_controller doesn't
restrict non-logged in users from adding products.
  Any words will be appreciated.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: requestAction(): returning html corrupted utf8

2008-08-18 Thread Steven Chan

Hi all,

I upgrade to the latest release candidate but that didn't fix it so I
decided to trace the code for requestAction(). Anway, that led me to
View::_render() and what I did to correct my problem was to put

header('Content-Type: text/html;
charset='.Configure::read('App.encoding'));
after the ob_start();

I'm not sure why this works but it solves the problem for me. Does
anyone else know if there is better method than hacking the core
files?

Steven

On Aug 18, 12:06 pm, Steven Chan <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I'm having some problems with requestAction(). I set the 'return' flag
> my utf-8 strings return from the action all corrupted. But if I call
> the action via Ajax or through a browser http request, it's ok.
>
> Does anyone know of a fix? I'm using cake 1.2 but it's not the latest
> release candidate.
>
> Steven
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Help with Model:find()

2008-08-18 Thread Kalt

For now, you defined the following relations :

- Account hasMany Purchase, Payment
- Purchase hasMany Payment

Right ? Now, try this :

// controllers/purchases_controller.php
function purchases_not_paid($account_id = null)
{
  // We trick the bindings
  $this->Purchase->unbindModel(array('hasMany' => array('Payment')));
  $this->Purchase->bindModel(array('hasOne' => array('Payment')));

  // Results
  $results = $this->Purchase->find('all', array('conditions' =>
array('Purchase.account_id' => $account_id, 'Payment.id' => null)));
  $this->set(compact('results'));
}

If you look at the debug, you will see that the SQL query is something
like that :

SELECT Puchase`.`id`, 
FROM `purchases` AS `Puchase`
LEFT JOIN `payments` AS `Payment`
ON (`Payment`.`purchase_id` = `Payment`.`id`)
WHERE `Purchase`.`account_id` = 1
AND `Payment`.`id` IS NULL

On 18 août, 04:36, lauren <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Using the Model::find() method seems to be preferred over using
> Model::query(). However, I can't seem to wrap my head around turning
> the following SQL query into params for the find() method:
>
> Pseudo code: select all the purchases that have not yet been paid for.
>
> SELECT p.*
> FROM accounts a, purchases p
> WHERE a.id = p.account_id AND p.id NOT IN (SELECT purchase_id FROM
> payments WHERE account_id = 1) AND a.id = 1;
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: keeping model cache might improve performace

2008-08-18 Thread stefanski

Thanks for your answers. I played around with the duration option -
Cache::config('_cake_core_', array('duration' => 1000) and
Cache::config('_cake_model_', array('duration' => 1000) but it had no
effect, the model cache seems to be rebuild every 10 seconds, which I
found out in cake/libs/model/datasources/datasource.php, line 389 :
$expires = "+10 seconds";

After changing that to $expires = "+1 day" my app is a lot faster now
for local development :-) if anybody knows how to set that in the
config/core.php, I'd be happy to know !

On Aug 17, 6:50 pm, Gwoo <[EMAIL PROTECTED]> wrote:
> Or you could set Cache::config('_cake_core_') in core.php to your own
> settings.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



ibm tutorial #2 on product addition

2008-08-18 Thread fourcs

Can't get the IBM tut #2 to restrict product addition to a logged-in
dealer.
Add function is below.

function add() {if (!empty($this->data)) {
//  $this->deconstruct();
  $this->Product->create();
  if ($this->Product->save($this->data)) {
  $dealer = $this->Product->Dealer->read(null,
   $this->data['Product']['dealer_id']);
  $parent = $this->Acl->Aco->findByAlias($dealer
['Dealer']['title']);
  $this->Acl->Aco->create(array(
   'alias' => $this->Product->id.'-'.$this->data
['Product']['title'],
   'model' => 'Product',
   'foreign_key' => $this->Product->id,
   'parent_id' => $parent['Aco']['id'])
);
  $this->Acl->Aco->save();
  $this->Acl->allow('Users',
  $this->Product->id.'-'.$this->data['Product']['title'],
'read');
  $this->Acl->allow($this->Session->read('user'),
  
$this->Product->id.'-'.$this->data['Product']
 ['title'],'*');
  $this->Session->setFlash('The Product has been saved');

  $this->redirect(array('action'=>'index'), null, true);
 } else {
  $this->Session->setFlash('The Product could not be saved.
  Please, try again.');
}
}
$dealers = $this->Product->Dealer->find('list');
$this->set(compact('dealers'));
}

Any ideas will be appreciated.

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



Re: Acl and Auth slow page load

2008-08-18 Thread Tiggr

Hi!

> var $components = array('Acl', 'Auth', 'Email');
>
> The page load goes through the roof.

Just the same for me, but only with Acl! And it isn't slow all the
time, pages load fast when user isn't logged in, but after logging in,
all is getting worse! Loadtime goes up through the roof because of the
many sql-queries acl does! :-(

I'm going to implement some sort of caching, but that's no real
solution, only a work around!

Is there a way to reduce the amount of queries in acl?

Bye
Marcus

PS: It's my first page with cake...! You may have a look at the page
at http://www.larp-welt.de, and at the code at
http://code.google.com/p/cakelinks/source/browse/.

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



How to handle multiple submit button in the controller

2008-08-18 Thread anus

Hi all,

 Iam a very new beginner to cakephp. Iam struggling with
multiple submit button in one form(via POST). This is my issue:

I have .ctp page with two submit button like this,

 create('Task', array('action' => 'home','type' =>
'post')); ?>
 submit('tasks.gif',array('name'=>'Task')); ?>
submit('Go',array('name'=>'Go')); ?>
 end(); ?>

I want to identify which button has clicked(Task button or Go button).
How can i identify this?I just tried like this..

And in my controller page I have an action "home" like this:
function home()
  {
if (isset($this->params['form']['Task']))
{
   echo("
window.alert(' Task') ");


}
  if (isset($this->params['form']['Go']))
{
   echo("
window.alert(' Go') ");


}

  }

But failed  can anyone plz help me. Struggling with this for last
few days!

Thanks



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



Re: Set the associated model id in beforeSave method?

2008-08-18 Thread Primeminister

He Brendon,

I always forget that 'on' thing ;) I tried:
'Duplicate' => array(
'rule'  => array('isUnique'),
'on'=> 'create',
'message'   => 'This nick is already taken. Choose
another or sign in'
)

But still is given me this validation message when I try to do $this-
>items->saveAll($this->data, array('validate'=>'first')));
Maybe the saveAll thinks that it is always a create.
It does do a SELECT on the authors table, but still comes back with
the 'Duplicate' validation error message.

Do I something wrong?

On Aug 15, 10:33 pm, BrendonKoz <[EMAIL PROTECTED]> wrote:
> In your rule that you set "isUnique", just make it so that the "on"
> key within that rule is set to "create" for the nickname field.
> Problem solved.
>
> On Aug 15, 3:58 am, Primeminister <[EMAIL PROTECTED]> wrote:
>
> > He Teknoid, thnx for your reply!
> > This works great, but I want an update if the nickname already exists
> > and an insert if not.
> > I thought in beforeSave() getting the ID of that nickname would be
> > sufficient.
>
> > Is there another way to do this with saveAll()? Or do I just have to
> > do save() twice (Items and Author)?
>
> > On Aug 14, 6:31 pm, teknoid <[EMAIL PROTECTED]> wrote:
>
> > > saveAll() will validate both of your models, and only save if both
> > > models pass validation.
> > > (Ensure that your DB supports transactions and use 'validate'=>'first'
> > > for options).
> > > This way you don't need any beforeSave() trickery, and you can rely on
> > > something like 'isUnique'
>
> > > saveAll() handles the rest...
>
> > > On Aug 14, 10:14 am, Primeminister <[EMAIL PROTECTED]> wrote:
>
> > > > Hi!
>
> > > > I use save all on Items which is associated with Authors (Item
> > > > belongsTo Author) and I have a beforeSave() in model Author which
> > > > checks if the nickname already exists and add the Author id to 
> > > > this->data when it does exists.
>
> > > > When I do $this->Item->saveAll() I print the $this->data in
> > > > Author.beforeSave()
> > > > Array
> > > > (
> > > >     [Author] => Array
> > > >         (
> > > >             [nick] => primeminister
> > > >             [modified] => 2008-08-14 14:09:08
> > > >             [created] => 2008-08-14 14:09:08
> > > >         )
>
> > > > )
>
> > > > I check if the author already exists. If yes then add it to $this-
>
> > > > >data :
>
> > > > Array
> > > > (
> > > >     [Author] => Array
> > > >         (
> > > >             [nick] => primeminister
> > > >             [modified] => 2008-08-14 14:09:08
> > > >             [created] => 2008-08-14 14:09:08
> > > >             [id] => 1
> > > >         )
> > > > )
>
> > > > But this ID is not used when saving the model Author record. It is
> > > > used but the with an INSERT statement.
> > > > Query: INSERT INTO `authors` (`nick`,`modified`,`created`,`id`) VALUES
> > > > ('primeminister','2008-08-14 14:09:08','2008-08-14 14:09:08',1)
>
> > > > How can I set this ID when using saveAll in items controller?
>
> > > > thnx!- Hide quoted text -
>
> > - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---