Note to self: Don't post long, meandering questions late on a Friday
afternoon :)

Jim

On Jul 23, 3:15 pm, geste <jim.ho...@gmail.com> wrote:
> A few days ago I asked how to best create a read-only interface from
> our Drupal intranet instance to our CakePHP business app (on the same
> host).  Galymzhan was nice enough to steer me to the CakePHP REST
> interface and that is the path I am following.
>
> I foresee a *lot* of simple functions that could be shared by both
> Cake and Drupal and that I would like to organize in a library.  A
> list of all users sorted by last and first name (to be used in drop-
> down menus, say) is the easiest example
>
> I created a 2nd DB configuration for Drupal to use REST.  It is
> identical to "default" except the DB user is one with only SQL SELECT
> privileges.  My idea is to create a "Lookup" Component and functions
> like the one in this prototype/example:
>
> /*********************/
>  class LookupComponent extends Object {
>     function PersonLastFirst(){
>      var $useDbConfig = 'lookup-readonly';
>      // Loading model/s required
>         App::import('Model', 'Person');
>         $this->Person = new Person();
>         $person_orderby = array('Person.lastname',
> 'Person.firstname');
>         $retval = $this->Person->find('list',array('order' =>
> $person_orderby));
>         var $useDbConfig = 'default';
>         return $retval;
>     }}
>
> /***********************/
>
> The idea would be that I would use these functions both for REST
> access from Drupal, but also for basic lookup functions inside the
> CakePHP app.
>
> As the perpetual neophyte, I am interested in any thoughts or warnings
> any of you can offer:
>
> Is a Component the right place to organize a bunch of functions that
> aren't tied to a single model?
>
> Can I access the same models with 2 different DB Configs?  I am not
> seeing why not but what do I know?
>
> Any problem if I start building functions that want to import multiple
> models to create a lookup list from a join?
>
> Am I going to regret loading models under a different DB config?  Like
> maybe wind up having 2 different Person objects in $this at the same
> time?  In the above example, does  this line:
>
>   $this->Person = new Person();
>
> need to be something like:
>
>   $this->PersonLastFirst = new Person();
>
> to remain unique?
>
> Please feel free to point out that big Clue I missed or any other
> ideas.  Thanks in advance and thanks for the help I have already
> received!
>
> Jim

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

Reply via email to