Monday, October 31, 2011

any one else having trouble with table prefixes in 2.0?

if the model cache is renewed everything is fine
but as soon as cake uses the model cache the table prefix is lost and
causes sql errors

the prefix is "site_"

query with cached data from /tmp/cache/models:

Error: SQLSTATE[42S02]: Base table or view not found: 1146 Table
'cake.addresses' doesn't exist

SQL Query: SELECT `Address`.`id`, `Address`.`foreign_id`,
`Address`.`model`, `Address`.`country_id`, `Address`.`first_name`,
`Address`.`last_name`, `Address`.`street`, `Address`.`postal_code`,
`Address`.`city`, `Address`.`lat`, `Address`.`lng`,
`Address`.`last_used`, `Address`.`formatted_address`,
`Address`.`type_id`, `Address`.`created`, `Address`.`modified` FROM
`addresses` AS `Address` WHERE `Address`.`foreign_id` = 4 AND
`Address`.`model` = 'Restaurant'

Notice: If you want to customize this error message, create site/View/
Errors/pdo_error.ctp

Stack Trace

#0 /srv/www/.../trunk/lib/Cake/Model/Datasource/DboSource.php(436):
PDOStatement->execute(Array)
#1 /srv/www/.../trunk/lib/Cake/Model/Datasource/DboSource.php(403):
DboSource->_execute('SELECT `Address...', Array)
#2 /srv/www/.../trunk/lib/Cake/Model/Datasource/DboSource.php(645):
DboSource->execute('SELECT `Address...', Array, Array)
#3 /srv/www/.../trunk/lib/Cake/Model/Datasource/DboSource.php(1205):
DboSource->fetchAll('SELECT `Address...', false)
#4 /srv/www/.../trunk/lib/Cake/Model/Datasource/DboSource.php(1226):
DboSource->queryAssociation(Object(Restaurant), Object(Address),
'hasOne', 'Address', Array, Array, true, Array, 0, Array)
#5 /srv/www/.../trunk/lib/Cake/Model/Datasource/DboSource.php(1065):
DboSource->queryAssociation(Object(Coupon), Object(Restaurant),
'belongsTo', 'Restaurant', Array, Array, true, Array, 1, Array)
#6 /srv/www/.../trunk/lib/Cake/Model/Model.php(2458): DboSource-
>read(Object(Coupon), Array)
#7 /srv/www/.../trunk/site/Plugin/Tools/Lib/MyModel.php(417): Model-
>find('all', Array, NULL, NULL)
#8 /srv/www/.../trunk/site/Controller/CouponsController.php(470):
MyModel->find('all', Array)
#9 [internal function]: CouponsController->homepage()
#10 /srv/www/.../trunk/lib/Cake/Controller/Controller.php(473):
ReflectionMethod->invokeArgs(Object(CouponsController), Array)
#11 /srv/www/.../trunk/lib/Cake/Routing/Dispatcher.php(107):
Controller->invokeAction(Object(CakeRequest))
#12 /srv/www/.../trunk/lib/Cake/Routing/Dispatcher.php(89): Dispatcher-
>_invoke(Object(CouponsController), Object(CakeRequest),
Object(CakeResponse))
#13 /srv/www/.../trunk/site/webroot/index.php(96): Dispatcher-
>dispatch(Object(CakeRequest), Object(CakeResponse))
#14 {main}


it should have been
"FROM `site_addresses` AS `Address`"

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Going back to school: ACL

You're welcome Eric ! :-)

As I wrote above, I think it worths to dive into ACL, even if it has
some limitations. But it was also immediately obvious to me that it
would be usable only with a graphical interface to manage the
permissions. That was the reason to write this plugin. And it is
probably obvious to many other users of ACL, since the plugin has been
downloaded many thousands of times since it is online.

Regarding a CakePHP 2.0 version, it is already available here:
http://www.alaxos.net/blaxos/posts/view/20 The reason to be still in
'beta' is that I haven't used it a lot so far. But it has been
downloaded a few tens of times already, and it seems to work quite
well. Feel free to try it and give me a feedback.


On Oct 30, 11:35 am, Eric Blanpied <sparkal...@gmail.com> wrote:
> Jeremy,
>
> I've done a number of cakephp apps (1.1, 1.2, 1.3 - starting a 2.0,
> too), and have also always been flummoxed by ACL and gone back to my
> own code to deal with it. A current project (1.3) has *lots* of roles,
> however, including enough overlap that a many-many groups-users setup
> seemed like what I wanted. I persevered with ACLs this time, though,
> and I'm ending up glad that I did. As others have said, pulling access
> control out of most of the code is very, very nice, and the
> flexibility to add new roles with mixed degrees of access via the
> database is great. I'm experimenting with hierarchical groups to
> handle some of the overlap (add a parent_id to your groups table).
>
> One thing that's helped me is Alaxos' acl plugin (thanks, nIcO!) -
> while it doesn't map to what I'm doing exactly, having some tools to
> manage the tables is vital, and I'm sure glad I didn't have to write
> any myself. One thing I'm curious about, nIcO, is the 2.0 story for
> your plugin.
>
> Zuha, can you explain a bit further about mixing prefix routing with
> ACLs? Our setup is currently still using admin_ prefixes, but as far
> as I can tell that's pretty redundant here, unless it could provide a
> second angle of access control.
>
> Thanks, everyone!
>
> -eric
>
>
>
>
>
>
>
> On Fri, Oct 28, 2011 at 11:08 AM, alaxos <ala...@gmail.com> wrote:
> > Hi Jeremy,
>
> > As far as I know, the core ACL does not support multiple groups per
> > user.
>
> > Before using ACL, I used myself a home made component that allowed to
> > grant/deny access based on roles membership and action prefixes like
> > you do. It used to work :-) and it also supported many-to-many users-
> > groups. But since I have changed my habit, and I now use ACL. As
> > mentionned by zuha, I prefer the idea to have the possibility to grant/
> > deny specific permission to someone or some people without having to
> > update the code. Even if it now does not support many-to-many users-
> > groups anymore, I think it is more flexible. But I also have to admit
> > that I never developped an application with a lot of different
> > profiles (so far 4-5 max).
>
> > nIcO
>
> > On Oct 27, 6:48 pm, Jeremy Burns | Class Outfit
> > <jeremybu...@classoutfit.com> wrote:
> >> Thanks Richard.
>
> >> Your point about flexibility and extensibility is a good one. You'd define specific views to do specific functions and then restrict them with permissions rather than a prefix. That also means one view can be used by more than one group (although I guess you could equally do that with $this->render).
>
> >> My second question is the one that puzzles me most. I've designed some systems where this is very typical; members of staff are department heads, managers, subordinates, team members, committee members and so on. So one person changes his role (group) throughout a single session. I'd be interested to see what others have to say too.
>
> >> I have some SQL that could speed up the acl table reads if you are using Innodb.
>
> >> Jeremy Burns
> >> Class Outfit
>
> >>http://www.classoutfit.com
>
> >> On 27 Oct 2011, at 17:32, zuha wrote:
>
> >> > #1 : Would require a prefix for every role.   admin_index, manager_index, user_index, guest_index, etc.   With ACL being database driven you can have unlimited user roles and not be required to add new prefixes every time you add a role.
>
> >> > #2 : I don't know, interesting question.  It sounds kind of a-typical to me though.  You would probably add a 3rd group in that rare case called something like, "board-teachers".
>
> >> > #3 : Yes and its not small.  It can be large and a major slow down.
>
> >> > ACL is very flexible but the flexibility comes with the downside of speed performance.  I'm quite sure there are caching solutions to get around it, but I have not gotten that far yet (even after 2 years of using ACL extensively).
>
> >> > --
> >> > Our newest site for the community: CakePHP Video Tutorialshttp://tv.cakephp.org
> >> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp others with their CakePHP related questions.
>
> >> > To unsubscribe from this group, send email to
> >> > cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php
>
> > --
> > Our newest site for the community: CakePHP Video Tutorialshttp://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com For more options, visit this group athttp://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Implementing a search functionality

I looked in the book on cakephp.org and didn't find the search behavior.  Do you mean some other book?  Did I miss what you're describing?

On Fri, Oct 28, 2011 at 10:38 PM, Jeremy Burns | Class Outfit <jeremyburns@classoutfit.com> wrote:
The answer (again) is in the error message. 'set' is a controller function and you are using it in a behaviour. set 'sets' a variable in the controller and passes it to the view. Here's the chain of events:

- user clicks a link or submits a form to a specified url
- that url is routed to a controller action (/controller/action/[parameters])
- the controller action does the stuff you tell it to
- this usually means calling some model functions, in your case the search method of the Provider model
- the model can use a behaviour method, in your case the search method of the Searchable behaviour (when a behaviour is attached to a model its methods are available as if they were native to the model)
- the model/behaviour performs database activity/business logic and returns variables to the calling controller function (note: 'return')
- the controller function receives those variables and 'sets' them ready for the view
- the controller then renders the view (generally of the same name as the controller action)
- the view renders html and can refer to the variables set and passed by the controller

Your code is not doing this.

Yves - can I recommend that you read the Cookbook? Amongst other things there is a really good Searchable behaviour out there that will do what you need.

Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 28 Oct 2011, at 22:11, Yves S. Garret wrote:

This is the structure of my folder tree and all of the pertinent files:
app\
  controllers\
    providers_controller.php [  http://bin.cakephp.org/view/1496172779  ]
  models\
    behaviors\
      searchable.php [  http://bin.cakephp.org/view/1269850925  ]
    provider.php [  http://bin.cakephp.org/view/1936681668  ]
  views\
    providers\
      view_admit_lookup.ctp [  http://bin.cakephp.org/view/1887805610  ]

The issue that I'm having is that when I try to search (say the word Smith), I get this error:

Fatal error: Call to undefined method SearchableBehavior::set() in D:\Inetpub\wwwroot-clinical\pythia-admit-lookup\app\models\behaviors\searchable.php on line 4

I find this confusing.  I'm already setting the last_name in my view... so shouldn't it be grabbing that info?

On Tue, Oct 25, 2011 at 3:00 PM, Yves S. Garret <yoursurrogategod@gmail.com> wrote:
Jeremy, thanks for your help.  I'll take the time to go through the blog tutorial at the moment.  I was kind of forced into this development process with little prep work or understanding of what's going on (the same would be to have you write a project in APL :-] ).

I'll get back to this thread after learning more about how Cake works and what it is capable of.


On Tue, Oct 25, 2011 at 2:30 PM, Jeremy Burns | Class Outfit <jeremyburns@classoutfit.com> wrote:
Your controller function sets variables and passes them to a view of the same name as the function. In your case, your function is called search_admit_lookup, so it will try to render a view called search_admit_lookup. That view will contain the logic to present whatever variables are set in the function and passed to the view. You can use whatever html you want in the view.


Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 25 Oct 2011, at 18:23, Yves S. Garret wrote:

It does not.  What I would like to do is to output the search results on a table right below the text box and search button.

Gonna look into that now.

On Tue, Oct 25, 2011 at 12:46 PM, Jeremy Burns | Class Outfit <jeremyburns@classoutfit.com> wrote:
The clue is in the error. Does that view exist? Your bin paste shows view_admit_lookup.ctp, not search_admit_lookup.ctp.


Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 25 Oct 2011, at 17:34, Yves S. Garret wrote:

Well, as annoying as it sounds, I just cleaned up the mess that was my previous implementation.

When I run the search, I'm getting this error:

Error: The view for ProvidersController::search_admit_lookup() was not found.

Error: Confirm you have created the file: D:\Inetpub\wwwroot-clinical\pythia-admit-lookup\app\views\providers\search_admit_lookup.ctp

Notice: If you want to customize this error message, create app\views\errors\missing_view.ctp


I got a meeting that I need to be at, I'll have a look after about 2 hours (hopefully it ends by then).


On Tue, Oct 25, 2011 at 11:38 AM, Jeremy Burns | Class Outfit <jeremyburns@classoutfit.com> wrote:
It's OK....

Yup - looks better now, and you are right you are setting the provider variable - I was looking at the wrong function. ^^

So are you all in the clear now?


Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 25 Oct 2011, at 16:26, Yves S. Garret wrote:

Oh, wait, God that was one hell of a copy/paste goof.  Sorry about that.

provider.php (Model):
providers_controller.php (Controller):
view_admit_lookup.ctp (View):


On Tue, Oct 25, 2011 at 11:07 AM, Jeremy Burns | Class Outfit <jeremyburns@classoutfit.com> wrote:
OK - but you still haven't applied all of the changes I outlined.

This line in your controller:
  1.     function view_admit_lookup() {
  2.         $this->set('provider'$this->paginate());

...is setting a variable called $provider with a value. That will be available in the view (view_admit_lookup) as $providers.

In your view you are looping through a variable called $Providers.

 <?php foreach ($Providers as $i => $prov)?>

$providers does not equal $Providers.

I'd change the controller to:

  1.     function view_admit_lookup() {
  2.         $this->set('providers'$this->paginate());

... and the view to

 <?php foreach ($providers as $i => $prov)?>

Also see my comment about your form name in the view (and the use of $form). To save you the tiresome task of actually reading anything and carrying out the instructions, let me correct it for you:

  1.     echo $this->Form->create("Provider"array('action' => 'search'));
  2.     echo $this->Form->input("doc_last_name"array('label' => 'Doctor Last Name'));
  3.     echo $this->Form->submit('Search');
  4.     echo $this->Form->end();

Also, the form is specifying that it posts to an action 'search' - does this exist in your providers controller? I can't see it.


Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 25 Oct 2011, at 15:57, Yves S. Garret wrote:

Yes, they're wrong.  But being new I was sure how correct/incorrect my approach was.  I'm working off of the stuff of another developer (who made the said file names).

This is what I have setup now:

app\
  controllers\
    providers_controller.php
  models\
    provider.php
  views\
    providers\
      view_admit_lookup.ctp

provider.php:
http://bin.cakephp.org/view/1833911095
providers_controller.php:



On Tue, Oct 25, 2011 at 10:10 AM, Jeremy Burns | Class Outfit <jeremyburns@classoutfit.com> wrote:
Why. Not. Read. My. Post? And the guide? With the link I sent you?

From this tree I can tell you that the model file should be lower case and that view is not named correctly. Lower case, with underscores, to match the controller function name (as I mention in my post(s)).

Once you have read the answers to your questions, applied the advice and adhered to conventions, please come back with any other errors.


Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 25 Oct 2011, at 14:19, Yves S. Garret wrote:

This time I'll include the file names and where they are:

app\
  controllers\
    providers_controller.php (has ProvidersController class)
  models\
    Provider.php (has Provider class)
  views\
    providers\
      viewAdmitLookup.ctp (contains all of the view display stuff)

On Tue, Oct 25, 2011 at 9:16 AM, Yves S. Garret <yoursurrogategod@gmail.com> wrote:
Thanks, this is the structure of my directory tree, tell me if I need to re-name anything:

app\
  controllers\
  models\
  views\
    providers\

Should I rename the providers directory to provider?


On Mon, Oct 24, 2011 at 11:33 PM, Jeremy Burns | Class Outfit <jeremyburns@classoutfit.com> wrote:
Your conventions are all over the place. Its best to stick to them.

Did you change the code inside the controller as suggested in my first post?

  1. class ProvidersController extends AppController {
  2.     var $name = 'Providers';

The filename is view_admit_lookup, yet the controller function is viewAdmitLookup - they should match. Change the function name to view_admit_lookup

In the view, you have this:

echo $form->create("Providers"array('action' => 'search'));

It'll create a form that tries to find the Providers model, not the Provider model. Change it to:

echo $form->create("Provider"array('action' => 'search'));

Change Providers to Provider throughout the view code.

In your controller function you have $this->set('providers'... which sends a variable $providers into the view, yet in the view you are iterating through a variable called $Providers. Change the variable in the view to $providers.

Your are using $form-> when you should be using $this->Form (that's the syntax for helpers in general, so $this->Html etc).

See this section of the book on conventions:


You can deviate from them with additional work, but it is not worth the effort else you'll run into issues like this.


Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 24 Oct 2011, at 22:39, Yves S. Garret wrote:

Ok, now I'm getting this when I turned everything to plural.

Missing Controller

Error: ProviderController could not be found.

Error: Create the class ProviderController below in file: app\controllers\provider_controller.php

<?php class ProviderController extends AppController {  	var $name = 'Provider'; } ?> 

Notice: If you want to customize this error message, create app\views\errors\missing_controller.ctp


Model:

http://bin.cakephp.org/view/361596401

View:

http://bin.cakephp.org/view/1786526282

Controller:

http://bin.cakephp.org/view/1385185838


On Mon, Oct 24, 2011 at 4:56 PM, Yves S. Garret <yoursurrogategod@gmail.com> wrote:
Yup.  CakePHP 1.3.  The view is in \app\views\providers\view_admit_lookup.ctp

The controller file name is providers_controller.php.  I added the variable that you suggested to the model file (which is called Provider.php) and I get the same error :-( .


On Mon, Oct 24, 2011 at 2:03 PM, Jeremy Burns | Class Outfit <jeremyburns@classoutfit.com> wrote:
Did you change anything? This is 1.3, right?

The filename should be providers_controller.php
Change the code as per my post below.
The view should be in /app/views/providers/
Add $var $name = 'Provider'; to the beginning of the Provider model file.


Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 24 Oct 2011, at 18:40, Yves S. Garret wrote:

This is my view:
This is my controller:
This is my model:

This is the error that I'm getting:

Missing Controller

Error: ProviderController could not be found.

Error: Create the class ProviderController below in file: app\controllers\provider_controller.php

<?php class ProviderController extends AppController {  	var $name = 'Provider'; } ?> 

Notice: If you want to customize this error message, create app\views\errors\missing_controller.ctp


:-/


On Mon, Oct 24, 2011 at 1:31 PM, Jeremy Burns | Class Outfit <jeremyburns@classoutfit.com> wrote:
Your controller names should be plural; try:

  1. class ProvidersController extends AppController {
  2.     var $name = 'Providers';


Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 24 Oct 2011, at 18:24, Yves S. Garret wrote:

Ok, this is weird.

I found this tutorial on doing searches.

That's good.  Now, this is my Model:
View:
Controller:

Now, when I run the search based on someone, I get something like this:

Missing Controller

Error: ProvidersController could not be found.

Error: Create the class ProvidersController below in file: app\controllers\providers_controller.php

<?php class ProvidersController extends AppController {  	var $name = 'Providers'; } ?> 

Notice: If you want to customize this error message, create app\views\errors\missing_controller.ctp

Now, I don't have Providers, I have Provider (singular only), so where is it getting the plural from?







On Fri, Oct 21, 2011 at 12:30 PM, Yves S. Garret <yoursurrogategod@gmail.com> wrote:
My question in that case would be, why am I getting that error?


On Thu, Oct 20, 2011 at 5:12 PM, Yves S. Garret <yoursurrogategod@gmail.com> wrote:
I have a decent understanding of what the tutorial is trying to do.  However, trying it to move it into my project is my present issue.

Here is my model:
Here is my controller:
Here is my view:

The issue that I get when I run Search:

Missing Controller

Error: ProvidersController could not be found.

Error: Create the class ProvidersController below in file: app\controllers\providers_controller.php

<?php class ProvidersController extends AppController {  	var $name = 'Providers'; } ?> 

Notice: If you want to customize this error message, create app\views\errors\missing_controller.ctp


provider_controller.php has a var $name = 'Providers'; as the name... 


On Tue, Oct 18, 2011 at 3:27 PM, Dee Johnson <devariojay@gmail.com> wrote:
my apologies, I saw where you said you wanted to make the tutorial simpler and i assumed that you already knew how to make calls etc. 

The tutorial is using a search behavior (which probably does the calls - i haven't looked to verify)

but to answer your question from above, I would recommend doing the tutorial OUTSIDE of your current project just to familiarize yourself with what it is asking you to do. 

Once you get that up and running you would have a much better understanding of what direction you would rather go in as a developer. 

so...yes...follow all steps in the tut. 

Now, if you are going away from the tutorial, you can just the data that comes back in the $this->data collection from your search box in the view and use that model call I used above.  If you dont understand this last bit, it is best you try the tutorial out first with a fresh install etc...so as not to disrupt your project or in the very least back it up.


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php




--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php



--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php



--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php



--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

CakePHP 2.0 Model relation alias, am I getting it wrong?

Hey guys, I'm rather new in CakePHP although I've developed a couple
small projects back in the 1.1 era.

I've been puzzled with the model relation alias behavior in 2.0
(behavior here used as literal english word not as the cakePHP
entity).

According to the docs one can name different model relation aliases
for the same model class, i.e.

class testExample extends AppModel {
public $hasMany = array(
'testRelation1' => array( //that's the alias
'className' => 'testRelation', //an existing model here
'foreignKey' => 'test_relation1_id' //existing key in database
),
'testRelation2' => array(
'className' => 'testRelation',
'foreignKey' => 'test_relation2_id' //another existing key in the
database
),
}

When the queries run, they return the expected results but those
results are not shown on page data, probably suppressed at some point.
The "Related Test Relation1" and "Related Test Relation2" come empty.

They only reason to get the data is to have the alias exactly as the
model class name:
public $hasMany = array(
'testRelation' => array( //same as model class name
'className' => 'testRelation',
'foreignKey' => 'test_relation1_id',
)

Even if you have just one relation like the last example and the alias
is not exactly the model name it doesn't work again.

Is this expected behavior?

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Going back to school: ACL

On Friday, October 28, 2011 4:08:42 PM UTC+7, alaxos wrote:
As far as I know, the core ACL does not support multiple groups per
user.

I believe ticket 770 has some discussion about this and a patch for 1.3.  However, I don't think that patch addresses the requirement where a user changes their group within a session.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: query

We have complicated queries that span across 8 tables. We decided to use pure SQL code. We defined our data source and run SQL through it defining our custom methods in the model that execute the query. If the query is just on one table we use the ORM but pure SQL pretty much in the other cases. The purpouse of the ORM layer is to make things easier. If you make it  more complicated, why are you doing it?

On Oct 31, 2011 1:55 AM, "WebbedIT" <paul@webbedit.co.uk> wrote:
Without seeing any of your code (model associations would have been
nice) I logically assume you are using Article HABTM Tag.

If so this does not create a model for the join table, but instead
puts in place some automagic to allow you to link many-to-many records
between the two models.  As such you can't run a find on the join
model, which is what you would have to do to be able to have
conditions spanning the three tables.

Your options are to use unbind and bind to force joins that you can
use:
http://nuts-and-bolts-of-cakephp.com/2008/08/06/habtm-and-join-trickery-with-cakephp/

Or, my preferred option is to create a model for join tables

Article hasMany ArticleTag
Tag hasMany ArticleTag
ArticleTag belongsTo Article, Tag

This allows you to easily add extra fields into your join table and to
run $this->Article->ArticleTag->find('all', array('conditions'=>array(
 'Article.is_read'=>0,
 'Article.status'=>1,
 'Tag.name'=>'cakephp'
)));

HTH, Paul.

P.S. Notice how I have changed some of your field names and values.
Your isRead field should be lowercased and underscored and if boolen
use tinyint(1) with 0 and 1.  When searching for articles by tag you
would normally recieve the tagname in the request (much better for
seo) so to query by Tag.id would require an extra find that I would
say is unneccessary when you can filter by Tag.name (especially if you
have the name field unique indexed).  I would also switch
Article.status for numerical values, ideally with a lookup table so
you can easily add/edit status text across all articles.



On Oct 30, 8:50 am, SERKAN TURAN <serkantu...@gmail.com> wrote:
> Hi,
> I have an query and I could not figure it out what is the cakephp form of
> it.
>
> query:
> -------------------------------------------
> SELECT *
> FROM
>   tags`
>   INNER JOIN `tags_articles` ON (`tags`.`id` = `tags_articles`.`tag_id`)
>   INNER JOIN `articles` ON (`tags_articles`.`article_id` = `articles`.`id`)
> WHERE
>   `articles`.`isRead` = 'Not' AND
>   `tags`.`id` = 3 AND
>   `articles`.`status` = 'New'
> ORDER BY
>   `articles`.`name` DESC
> --------------------------------------------------------------------------- -------------------
>
> Thnks..
> ST

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: query

Without seeing any of your code (model associations would have been
nice) I logically assume you are using Article HABTM Tag.

If so this does not create a model for the join table, but instead
puts in place some automagic to allow you to link many-to-many records
between the two models. As such you can't run a find on the join
model, which is what you would have to do to be able to have
conditions spanning the three tables.

Your options are to use unbind and bind to force joins that you can
use:
http://nuts-and-bolts-of-cakephp.com/2008/08/06/habtm-and-join-trickery-with-cakephp/

Or, my preferred option is to create a model for join tables

Article hasMany ArticleTag
Tag hasMany ArticleTag
ArticleTag belongsTo Article, Tag

This allows you to easily add extra fields into your join table and to
run $this->Article->ArticleTag->find('all', array('conditions'=>array(
'Article.is_read'=>0,
'Article.status'=>1,
'Tag.name'=>'cakephp'
)));

HTH, Paul.

P.S. Notice how I have changed some of your field names and values.
Your isRead field should be lowercased and underscored and if boolen
use tinyint(1) with 0 and 1. When searching for articles by tag you
would normally recieve the tagname in the request (much better for
seo) so to query by Tag.id would require an extra find that I would
say is unneccessary when you can filter by Tag.name (especially if you
have the name field unique indexed). I would also switch
Article.status for numerical values, ideally with a lookup table so
you can easily add/edit status text across all articles.

On Oct 30, 8:50 am, SERKAN TURAN <serkantu...@gmail.com> wrote:
> Hi,
> I have an query and I could not figure it out what is the cakephp form of
> it.
>
> query:
> -------------------------------------------
> SELECT *
> FROM
>   tags`
>   INNER JOIN `tags_articles` ON (`tags`.`id` = `tags_articles`.`tag_id`)
>   INNER JOIN `articles` ON (`tags_articles`.`article_id` = `articles`.`id`)
> WHERE
>   `articles`.`isRead` = 'Not' AND
>   `tags`.`id` = 3 AND
>   `articles`.`status` = 'New'
> ORDER BY
>   `articles`.`name` DESC
> --------------------------------------------------------------------------- -------------------
>
> Thnks..
> ST

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php