Dealing with mysql views in schema generation

2012-11-05 Thread Greg Skerman
Hi,

For one of my projects, I need to join up against some static data in
another database. The data in this database will never be written to by my
application, and the schema does not comply with cake's conventions. I am
not able to change the schema to comply with cake's conventions because
other non-cake applications depend on and have been written to take
advantage of this schema.

As such, I've turned to mysql views - a simple select query massages the
format into something cake is comfortable with and this works fine for
feeding the static data/lookups on static data into my application.

The problem comes when I try and generate a schema with the schema shell.
It generates fine but the schema creates entries for the views as if they
were tables, so there is a manual task after the fact to go back in and
remove the entries for the views, and then a manual SQL script to create
the views.. which is prone to user error (if schemas are run but views are
not updated, or views are not removed from schema.php etc).

Does anyone have a nice elegant way of dealing with views in schema
generation?

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
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.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Passing variables between AppController and Models / Access Auth data in Models

2012-11-05 Thread Nir Regev
Hi all !

I need to implement a little complex user permissions over data in tables :

relations are similar to the following :

- user belongs to a customer
- book belongs to a customer

In order to keep it DRY and "fat model / slim controller", I thought I 
could just add something like :

// Book Model
$queryData['conditions']['customer_id']=$this->Auth->User['customer_id'];

But, I don't get how to access Auth parameters from the models.

The only way I found to pass this barrier is to send the user's customer_id 
via the $_SESSION which is quite .. err .. ugly :)

Any suggestions on how to pass parameters to all models ?

Note that I need the customer_id available for all models, not just "Book" 
..

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
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.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Issues with digest authentication - need some help

2012-11-05 Thread Nir Regev
This does not seem to help :(

I've added a log to watch when / which user arrives at isAuthorized and 
found out that when using BASIC authentication, I can see the user without 
a problem but when using DIGEST the isAuthorized function does not run at 
all.

Another thing about all this : when allowing DIGEST only, using a browser I 
can login without a problem, the issue seems to appear only when using CURL 
(--digest of course)

Using curl in verbose mode I can see that it gets a 302 response without 
any expected DIGEST data (such as realm etc.)

Any further suggestions ?

10x.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
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.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: "Manual rollback": is it neccsessary to set id after an insert if deleting?

2012-11-05 Thread Igor Lacik
Why dont you put the if *($this->Utils->sendEmail($email_to, $username,
$id))* condition in the beginning of your function (parameters will be
those you receive in $this->request->data).

Eg.:

if *($this->Utils->sendEmail($this->request->data['User']['email'], **
$this->request->data['User']['name']**,*$this->User->getLastInsertID() +1*))
{*
*  $this->User->create();*
*   etc..*
*}*

(maybe you will have to override the $this->Util->sendEmail function to
return false if it failed, but that's easy)

On Mon, Nov 5, 2012 at 9:53 PM, Daniel  wrote:

> I've got some of code that looks like:
>
> $this->User->create();
> if ($this->User->save($this->request->data)) {
>   // ... do some other stuff
>   $this->User->Profile->create();
>   if $this->User->Profile->save($profile) {
> if ($this->Utils->sendEmail($email_to, $username, $id)) {
>   $this->Session->setFlash(__('The account has been created.'));
> What I want to do is delete the user and profile records if the sendEmail
> fails, sort of like doing a manual transaction rollback.
> What I want to know is:  is it neccessary to set the id before calling
> delete?  e.g. do I need to use getLastInsertID() or will the value already
> be set:
>
> $this->User->delete();
> or:
> $this->User->id = $this->User->getLastInsertID();
> $this->User->delete();
> Thanks.
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> 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.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
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.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




"Manual rollback": is it neccsessary to set id after an insert if deleting?

2012-11-05 Thread Daniel
I've got some of code that looks like:
 
$this->User->create();
if ($this->User->save($this->request->data)) {
  // ... do some other stuff
  $this->User->Profile->create();
  if $this->User->Profile->save($profile) {
if ($this->Utils->sendEmail($email_to, $username, $id)) {
  $this->Session->setFlash(__('The account has been created.'));
What I want to do is delete the user and profile records if the sendEmail 
fails, sort of like doing a manual transaction rollback.
What I want to know is:  is it neccessary to set the id before calling 
delete?  e.g. do I need to use getLastInsertID() or will the value already 
be set:
 
$this->User->delete();
or:
$this->User->id = $this->User->getLastInsertID();
$this->User->delete();
Thanks.

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
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.
Visit this group at http://groups.google.com/group/cake-php?hl=en.