Re: [SOLVED] Calling functions in other controllers
the best place to start is with the book. http://book.cakephp.org/2.0/en/index.html Read through and work through the example applications On Wednesday, February 27, 2013 12:10:27 PM UTC-5, Ganapathi Raman wrote: > > Hi Friends, > >I am new to the Cake-PHP...I don't know how to start and where to > start...So,Please guide me.. > > Regards, > > Ganapathi Raman.p > -- 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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Upgrading from 1.3.15 to 2.2.7 or 2.3
One more question. I currently have an application on 1.3.15 and want to use the upgrade-shell. Can I upgrade straight to 2.2.7 or 2.3 rather than the 2.0 branch that is generically mentioned in http://book.cakephp.org/2.0/en/console-and-shells/upgrade-shell.html#upgrade-shell. I tried a quick run through of the instructions with 2.0.6 and ran into some issues with the upgrade shell. I have not investigated the further but my app_controller was renamed to "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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
[SOLVED] Calling functions in other controllers
Hello David, Thanks very much for jogging my memory. I was not trying to do anything out of scope but just have re-usable functions that I can call in other controllers. I moved the getCart, and totals into the cart model and was able to greatly simplify my code. Everything is working like a champ. Thanks for the help from everyone. Brian On Wednesday, February 27, 2013 8:03:24 AM UTC-5, david...@gmail.com wrote: > > > On Wednesday, February 27, 2013 2:55:53 AM UTC+2, lirc201 wrote: >> >> I'm in 2 different controllers. In the checkout controller, I'm trying >> to call a function in the cart controller. >> >> Are you sure that the function is in the cart controller? The $uses > variable indicates which other models this model will use (not which other > controllers). If you want to call a method on another controller you will > need to use either App::Import or RequestAction. If the error you are > getting is an SQL error rather than a method not found error it would seem > like the get() method is on the model. > > In general, many people will tell you that calling one controller from > another is a bad idea and should only be done as a last resort. > > If it is true that you are managing to call a controller method then it > may be simpler to move these methods into the Cart model which you would > then be able to access from the $uses variable. > > If the methods are really on the model (or if you choose to move them > there) you will need to be acting on a particular instance of Cart so you > would do something like: > $this->Cart->id = $CartID; // assumes you already have the id of the cart > you want > $Cart = $this->Cart->get(); // assumes that the only state information > that get needs is the id and will read any additional information for itself > > Alternatively, you may need to find the cart you are looking for and pass > that information into the get call. I.e. > $Cart = $this->Cart->find('first', array('conditions' => > array('Cart.customer_id' => $CustomerID))); > $Total = $this->Cart->total($Cart); > > As a side note: > One debugging method you could use when confronted with this type of > situation is to copy and paste the query that generated the error directly > into something like PhpMyAdmin and see what part of the query is causing > the SQL error. My guess is that in your case the query has a where clause > with 'WHERE Cart.id=' with no id specified or something like that. > > -- 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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Calling functions in other controllers
I'm in 2 different controllers. In the checkout controller, I'm trying to call a function in the cart controller. On Tuesday, February 26, 2013 7:34:39 PM UTC-5, jsundquist wrote: > > If you are in the function trying to call another function just do > $this->get() not $this->cart->get() > On Feb 26, 2013 6:32 PM, "lirc201" > > wrote: > >> I'm still working in cake 1.3.15 (going to upgrade soon) but running into >> an issue. I'm setting up a shopping cart so I have functions in my >> cart_controller like >> >> Cart get() >> Cart total() >> >> When I attempt to call these functions in my checkout_controller ... >> >> var $uses = ('Cart',,,); >> >> function index() { >> $cart = $this->Cart->get(); >> $total = $this->Cart->total(); >> >> When checking out I get an SQL error about incorrect mysql syntax ... >> check the manual ... the next line reads "Query: get". If I pull the >> "get" code into the checkout_controller it runs as expected. >> >> What I'm I missing? >> >> Thanks, >> Brian >> >> -- >> 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 unsubscribe from this group and stop receiving emails from it, send an >> email to cake-php+u...@googlegroups.com . >> To post to this group, send email to cake...@googlegroups.com >> . >> Visit this group at http://groups.google.com/group/cake-php?hl=en. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > -- 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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Calling functions in other controllers
I'm still working in cake 1.3.15 (going to upgrade soon) but running into an issue. I'm setting up a shopping cart so I have functions in my cart_controller like Cart get() Cart total() When I attempt to call these functions in my checkout_controller ... var $uses = ('Cart',,,); function index() { $cart = $this->Cart->get(); $total = $this->Cart->total(); When checking out I get an SQL error about incorrect mysql syntax ... check the manual ... the next line reads "Query: get". If I pull the "get" code into the checkout_controller it runs as expected. What I'm I missing? Thanks, Brian -- 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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Selecting hasMany fields
I have an Order that hasMany LineItems. I only want to extract an Order if certain LineItems.fields meet my conditions. I'm using $this->Order->find('list', array( 'conditions' => array('LineItem.event_id' => '3', 'LineItem.pulled' => '1'), //'order' => array(Order.id => 'asc'), 'recursive' => '2' )); However all I get is ALL Orders. Any ideas, thanks Brian -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Help with update
Ryan, You are completely right about the atomic operation. The below works well with a hard coded value, but I need to insert $quantity since that will vary based on the adjustment needed from an order or stock being added. I'm stuck with the code change into the literal value there. $this->updateAll( array('Venue.inventory' => 'Venue.inventory+$quantity'), array('Venue.id' => $id)); Thanks, Brian On Mar 1, 2:06 pm, Ryan Schmidt wrote: > On Mar 1, 2011, at 12:46, Ryan Schmidt wrote: > > > > > On Mar 1, 2011, at 11:35, lirc201 wrote: > > >> I like the example on the weblink which is just using MySQL > >> functionality, it is very clever. Thanks for the help and push. My > >> code is working! I did like the security tricks I discovered for my > >> updates below to only pass a field list. > > >> function updateInventory($id, $quantity) { > >> $inv = $this->getQuantity($id); <- function is in the > >> same model > >> $this->data['Model']['id'] = $id; > >> $this->data['Model']['inventory'] = $inv + $quantity; > >> if($this->save($this->data, array( > >> 'validate' => 'false', > >> 'fieldList' => array('id', > >> 'inventory' { > >> ... logic for return values ... > >> } > >> } > > > This is not atomic. Between the line where you get the current quantity and > > the line where you save the updated quantity, someone else might have > > updated the quantity, and you'd be wiping out their change. Consider two > > managers simultaneously adding 5 to the inventory of the same item. The > > expected result would be that in the end the inventory is incremented by > > 10, but because of the race condition in your code, it might only be > > incremented by 5. > > The problem is more apparent if you think about the case of a customer buying > an item on your site and decreasing the inventory. > > Let's say your inventory for item id 3 is 10, and you have two users about to > buy one each of item id 3. Both users happen to click the Buy button at the > same instant, which will cause the method updateInventory(3, -1) to be called > for each user. If this method runs at the same time for both users, then for > both users getQuantity() will return 10, in both cases you'll add $quantity > to it, thereby decreasing it by one, and in both cases you'll save 9 to the > database -- even though two users have successfully bought the item and the > inventory should now be 8. Clearly this will be a problem as your database > might say you have more quantity than you actually do and customers will try > to buy product you no longer have. > > The solution is to use a single atomic SQL UPDATE statement, as I showed > earlier (or rather, the CakePHP equivalent of that), or use an SQL > transaction (and ensure your database supports transactions -- for example > for MySQL, you'd use InnoDB tables instead of MyISAM). -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Help with update
Here is the updated code. I've deciding on increasing or decreasing in the calling controller. If you want to decrease the inventory numbers than pass a negative $quantity. This was the interface I chose because I will have several different controllers calling this function to make updates to the inventory numbers, like when more inventory is added. I like the example on the weblink which is just using MySQL functionality, it is very clever. Thanks for the help and push. My code is working! I did like the security tricks I discovered for my updates below to only pass a field list. function updateInventory($id, $quantity) { $inv = $this->getQuantity($id); <- function is in the same model $this->data['Model']['id'] = $id; $this->data['Model']['inventory'] = $inv + $quantity; if($this->save($this->data, array( 'validate' => 'false', 'fieldList' => array('id', 'inventory' { ... logic for return values ... } } On Mar 1, 12:03 pm, cricket wrote: > On Tue, Mar 1, 2011 at 10:42 AM, lirc201 wrote: > > Hello, > > > I'm trying to perform an update to my model in order to reflect a > > change in the inventory value. The values that I'm passing to $id, > > and $quantity below are correct, but even with a hard coded value of 5 > > the database still gets updated with a 0 for the inventory field for > > the given id. This leads me to think I'm not passing the information > > correctly to $this->save as I was using an update example from the 1.3 > > book for Saving Data. > > > In Model: > > > function updateInventory($id, $quantity) { > > > $this->id = $id; > > $this->inventory = '5'; > > if($this->save($this->data, array('validate' => 'false', > > 'fieldList' => array('id', > > 'inventory' { > > . > > > } > > There is no $inventory class member. There is an $id, though. What you > need to do is construct an array and pass that to save(). Using > $this->data is fine but it's not apparent here that it contains the > correct data at all. The array should look like: > > array( > 'YourModelName' => array( > 'id' => $id, > 'inventory' => $inventory > ) > ) > > But there are simpler ways to do > this:http://nuts-and-bolts-of-cakephp.com/2008/05/22/incrementing-a-field-... > > Also, is the $quantity param the number of items that inventory has > changed by? How are you deciding whether to increase or decrease by > that amount? -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Help with update
Hello, I'm trying to perform an update to my model in order to reflect a change in the inventory value. The values that I'm passing to $id, and $quantity below are correct, but even with a hard coded value of 5 the database still gets updated with a 0 for the inventory field for the given id. This leads me to think I'm not passing the information correctly to $this->save as I was using an update example from the 1.3 book for Saving Data. In Model: function updateInventory($id, $quantity) { $this->id = $id; $this->inventory = '5'; if($this->save($this->data, array('validate' => 'false', 'fieldList' => array('id', 'inventory' { . } Thanks, Brian -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Redirecting from admin to front page
Thanks K! On Feb 21, 2:29 pm, "Krissy Masters" wrote: > Add 'admin' => false > > echo $this->Html->link(__('ORDER - New', true), array('controller' => > 'events', 'action' => 'index', 'admin' => false)); > > K > > -Original Message- > From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf > > Of lirc201 > Sent: Monday, February 21, 2011 3:51 PM > To: CakePHP > Subject: Redirecting from admin to front page > > Hello All, > > I've been struggling with links in my admin area to allow for > redirecting to my front page. I have some admin functions that I do > not want to have in the admin section. Mainly I want admins to be > able to enter orders for customers using the same screens as a regular > web user would (with more options). Anyways I post a link like > > echo $this->Html->link(__('ORDER - New', true), array('controller' => > 'events', 'action' => 'index')); > > Where I have a /events/index, and a /admin/events/index. With this > code in the admin area, I want to redirect to /events/index. However > it is assuming that I meant to say /admin/events/index. How can I get > around this? > > Thanks, > Brian > > -- > 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+unsubscr...@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Redirecting from admin to front page
Hello All, I've been struggling with links in my admin area to allow for redirecting to my front page. I have some admin functions that I do not want to have in the admin section. Mainly I want admins to be able to enter orders for customers using the same screens as a regular web user would (with more options). Anyways I post a link like echo $this->Html->link(__('ORDER - New', true), array('controller' => 'events', 'action' => 'index')); Where I have a /events/index, and a /admin/events/index. With this code in the admin area, I want to redirect to /events/index. However it is assuming that I meant to say /admin/events/index. How can I get around this? Thanks, Brian -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Automagic on add()
There is automagic! I needed to do $this->data instead of $this- >set('data', $data); l8r, Brian On Feb 15, 6:52 pm, lirc201 wrote: > I've developed a method for generating a $data array for a given model > so that I can prefill various fields on an add() form. My users will > be using the add form often and I would like default values in there > based on $data being pulled from a Settings model. I've tested and > $data[Model][parameter][value] works when [parameter][value]> but I'm looking for a more automatic method > similar to populating an edit form. > > Thanks, > Brian -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Automagic on add()
I've developed a method for generating a $data array for a given model so that I can prefill various fields on an add() form. My users will be using the add form often and I would like default values in there based on $data being pulled from a Settings model. I've tested and $data[Model][parameter][value] works when but I'm looking for a more automatic method similar to populating an edit form. Thanks, Brian -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Help with multiple foreachs
Anthony, Thanks. debug is similar to pr but a little better. I went in, removed all of the code and just re-wrote it. By doing that it worked right out of the box. Also thanks to Bart. Happy Baking, Brian On Dec 7, 8:45 am, Anthony wrote: > Use debug($events) to visualize your data. > > You should be able to see what your doing wrong. Your issue isn't > really bizarre or difficult its more like your trying to guess at what > your array of data should look like instead of just looking at it. > > On Dec 5, 10:53 pm, lirc201 wrote: > > > That is actually what I have with the nested foreachs but I still get > > undefined variable ticket. Event HasMany Venues HasMany Tickets. The > > "Related Venues" functionality (as generated by bake) is > > $event['Venue']. The undefined variable ticket is coming in on the > > line "echo $ticket['price']". This is a very bizarre issue. I can > > display echo pr($venue[['Ticket']) and see the [0] ... and [1] > > tickets that I'm expecting to see what the arrays are not getting > > assigned to $ticket in the second foreach loop. > > > Thanks, > > Brian > > > On Dec 5, 2:37 pm, Bart wrote: > > > > Your data structure is not completely clear, but I presume the ticket- > > > loop is nested in the venue-loop because a Venue has multiple tickets. > > > In that case the base-node for your ticket loop should be $venue, and > > > not $event['Venue']. > > > Like this: > > > > foreach($event['Venue'] as $venue){ > > > foreach($venue['Ticket'] as $ticket){ > > > echo $ticket['price']; > > > } > > > > } > > > > On Dec 5, 4:50 pm, lirc201 wrote: > > > > > I've been looking at this way too long and need a little push. I'm > > > > trying to display all of the available tickets for all venues that are > > > > part of a selected event. I have the recursion correct for my model > > > > call. My first foreach loop > > > > > foreach $event['Venue'] as $venue > > > > > this displays all of the information for each venue > > > > > the next nested foreach loop is where I'm having difficulty trying to > > > > get correct. > > > > > I've played with this foreach ($event['Venue'] as $ticket) but keep > > > > getting an ... undefined variable ticket ... when I try to echo > > > > $ticket['displayName'], however I see the results I want if I debug > > > > display $event['Venue'][0]['Ticket'] > > > > > I'm using cake 1.3.6 > > > > > Thanks, > > > > Brian 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
Re: Help with multiple foreachs
That is actually what I have with the nested foreachs but I still get undefined variable ticket. Event HasMany Venues HasMany Tickets. The "Related Venues" functionality (as generated by bake) is $event['Venue']. The undefined variable ticket is coming in on the line "echo $ticket['price']". This is a very bizarre issue. I can display echo pr($venue[['Ticket']) and see the [0] ... and [1] tickets that I'm expecting to see what the arrays are not getting assigned to $ticket in the second foreach loop. Thanks, Brian On Dec 5, 2:37 pm, Bart wrote: > Your data structure is not completely clear, but I presume the ticket- > loop is nested in the venue-loop because a Venue has multiple tickets. > In that case the base-node for your ticket loop should be $venue, and > not $event['Venue']. > Like this: > > foreach($event['Venue'] as $venue){ > foreach($venue['Ticket'] as $ticket){ > echo $ticket['price']; > } > > } > > On Dec 5, 4:50 pm, lirc201 wrote: > > > I've been looking at this way too long and need a little push. I'm > > trying to display all of the available tickets for all venues that are > > part of a selected event. I have the recursion correct for my model > > call. My first foreach loop > > > foreach $event['Venue'] as $venue > > > this displays all of the information for each venue > > > the next nested foreach loop is where I'm having difficulty trying to > > get correct. > > > I've played with this foreach ($event['Venue'] as $ticket) but keep > > getting an ... undefined variable ticket ... when I try to echo > > $ticket['displayName'], however I see the results I want if I debug > > display $event['Venue'][0]['Ticket'] > > > I'm using cake 1.3.6 > > > Thanks, > > Brian 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
Help with multiple foreachs
I've been looking at this way too long and need a little push. I'm trying to display all of the available tickets for all venues that are part of a selected event. I have the recursion correct for my model call. My first foreach loop foreach $event['Venue'] as $venue this displays all of the information for each venue the next nested foreach loop is where I'm having difficulty trying to get correct. I've played with this foreach ($event['Venue'] as $ticket) but keep getting an ... undefined variable ticket ... when I try to echo $ticket['displayName'], however I see the results I want if I debug display $event['Venue'][0]['Ticket'] I'm using cake 1.3.6 Thanks, Brian 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
Enable access to / without Auth
I've enabled Auth for my controllers and protected various actions for my application, however http://mysite.com/ immediately goes to the login screen. In app_controller, beforefilter function, I've added $this->Auth->allow('index'); line but it is still prompting for login. How can I enable public access to the initial page of my site? 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
Re: Password field not encrypting
Thanks to all, moving the $this->Auth settings to local "beforeFilter"s in the users controller did the trick. On Feb 23, 12:23 pm, brian wrote: > On Mon, Feb 23, 2009 at 11:41 AM, lirc201 wrote: > > > The beforeFilter is in app_controller. I was wanting the settings to > > be universal, although the more I think about it now perhaps it just > > needs to be in the Users controller. I assumed the beforeFilter in > > app_controller would always be called automatically. I'm not 100%, > > still learning. > > If you have a beforeFilter method defined in any controller that > extends AppController and you do not call parent::beforeFilter() then > the method in AppController will not run. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Password field not encrypting
The beforeFilter is in app_controller. I was wanting the settings to be universal, although the more I think about it now perhaps it just needs to be in the Users controller. I assumed the beforeFilter in app_controller would always be called automatically. I'm not 100%, still learning. On Feb 23, 11:18 am, "dr. Hannibal Lecter" wrote: > Do you have beforeFilter() in your users controller? Are you calling > parent::beforeFilter()? > > On Feb 23, 3:39 pm, lirc201 wrote: > > > I'm trying to implement the Auth component for the first time into my > > application. On my registration page I noticed that the password was > > getting inserted into the database as plain text. The application > > does not use the default names "username" and "password" so I defined > > the fields as stated in the documentation. > > > app_controller: > > > function beforeFilter() { > > > // Configure Authuentication Component > > $this->Auth->loginAction = array( > > 'controller' => 'users', > > 'action' => 'login' > > ); > > $this->Auth->fields = array( > > 'username' => 'email', > > 'password' => 'passwd' > > ); > > > $this->Auth->authorize = 'controller'; > > $this->Auth->logoutRedirect = "/"; > > $this->Auth->loginError = 'Invalid email/password combination, > > please try again.'; > > } > > > So in my "signup" code I added: > > $this->data['User']['passwd'] = $this->Auth->password($this->data > > ['User']['passwd']); > > to get the encrypted password put into the database, and that seems to > > work. Next I proceed to the login page to test the new account > > (standard login, cut and pasted code from documentation, but using my > > email, and passwd fields). I then get my Auth->loginError, which I > > believe is because the password is not getting encrypted > > automatically. > > > I was under the impression that by using the $this->Auth->fields, that > > the automagic would still work for me. Does the Auth->fields work as > > intended? > > > Thanks, > > Brian --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Password field not encrypting
I'm trying to implement the Auth component for the first time into my application. On my registration page I noticed that the password was getting inserted into the database as plain text. The application does not use the default names "username" and "password" so I defined the fields as stated in the documentation. app_controller: function beforeFilter() { // Configure Authuentication Component $this->Auth->loginAction = array( 'controller' => 'users', 'action' => 'login' ); $this->Auth->fields = array( 'username' => 'email', 'password' => 'passwd' ); $this->Auth->authorize = 'controller'; $this->Auth->logoutRedirect = "/"; $this->Auth->loginError = 'Invalid email/password combination, please try again.'; } So in my "signup" code I added: $this->data['User']['passwd'] = $this->Auth->password($this->data ['User']['passwd']); to get the encrypted password put into the database, and that seems to work. Next I proceed to the login page to test the new account (standard login, cut and pasted code from documentation, but using my email, and passwd fields). I then get my Auth->loginError, which I believe is because the password is not getting encrypted automatically. I was under the impression that by using the $this->Auth->fields, that the automagic would still work for me. Does the Auth->fields work as intended? Thanks, Brian --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Help with URL parameters
I'm passing a URL /tickets/add/1 by using the following code link(__('Add Tickets', true), array ('controller'=>'tickets','action'=>'add', $venue['Venue']['id'])); ?> My question is how do I grab the $venue[Venue][id] value when it is passed to my Tickets controller? Is it $this->data[id]? Thanks, Brian --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Queries based on
Amazingly I landed on all fours. : ) Thanks for the help On Nov 11, 7:10 pm, "David C. Zentgraf" <[EMAIL PROTECTED]> wrote: > This should certainly work: > $this->set('events', $this->Event->find('all', array('conditions' => > array('Event.associate_id' => $curr_user["Associate"]["0"]["id"]; > > Good flight! WEe~ > > On 12 Nov 2008, at 08:59, lirc201 wrote: > > > > > Hello All, > > > I need a little push off the cliff here. I want this query to return > > all entries where the associate_id = some value ( WHERE associate_id = > > '??'). > > > $this->set('events', $this->Event->find('all', array('associate_id' => > > '$curr_user["Associate"]["0"]["id"]'))); > > > $curr_user will be defined with some INT(11) value. > > > I'm using 1.2 RC3. > > > Thanks, > > Brian --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Queries based on
Hello All, I need a little push off the cliff here. I want this query to return all entries where the associate_id = some value ( WHERE associate_id = '??'). $this->set('events', $this->Event->find('all', array('associate_id' => '$curr_user["Associate"]["0"]["id"]'))); $curr_user will be defined with some INT(11) value. I'm using 1.2 RC3. Thanks, Brian --~--~-~--~~~---~--~~ 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: HABTM Relationship and Multiple Models
I finally figured it out or at least one way of doing it. Step 1 - Unbind the HABTM with the Associate model Step 2 - Save User model data Step 3 - bind HABTM with Associate model Step 4 - save data['User']['id'] = getLastInsertID <- for the automagic to happen!!! Step 5 - Save Associate data Thanks for the suggestions. Brian On Jul 2, 2:15 pm, lirc201 <[EMAIL PROTECTED]> wrote: > What is the "with" option? > > On Jul 2, 1:30 pm, francky06l <[EMAIL PROTECTED]> wrote: > > > If you use a join model (ie:HABTM) using 'with' option, the saveAll > > will work if you also save the Associate (saving User, Associate and > > the with Model). > > If you do not have the Associate to save, just unbind and bind as > > hasMany your liked model (the with), and call saveAll... > > > hth > > > On Jul 2, 6:28 pm, James K <[EMAIL PROTECTED]> wrote: > > > > It's best to just make a model for your join table, populate it > > > manually and save it separately. There is an "automagic" way to do it > > > - which is described in the manual - but it's just as much work and > > > not very intuitive. The way the automagic works is you have to add an > > > array of Associate keys you want to save into the join table in the > > > User data collection (or vice-versa depending on which is the parent > > > model). Then when you do user->save, it'll see that collection of keys > > > and populate the join table. > > > > On Jul 1, 1:44 pm, lirc201 <[EMAIL PROTECTED]> wrote: > > > > > Hello All, > > > > > I'm stuck and need a jump start here. I have a form that collections > > > > User model and Associate model data. User like email, password and > > > > Associate like street, city, state, etc... data. I have aHABTM > > > > relationship between User and Associate. My question is how to make > > > > the linkage work? In this case I'm assuming that both the User and > > > > Associate data enter is new. > > > > > $this->User->save($this->data); > > > > $user_id = $this->User->getLastInsertId(); > > > > > at this point do I just this: > > > > $this->data['User']['id'] = $user_id; > > > > $this->Associate->save($this->data); > > > > > Will the join table get popualted? > > > > > Thanks, > > > > Brian --~--~-~--~~~---~--~~ 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: HABTM Relationship and Multiple Models
What is the "with" option? On Jul 2, 1:30 pm, francky06l <[EMAIL PROTECTED]> wrote: > If you use a join model (ie: HABTM) using 'with' option, the saveAll > will work if you also save the Associate (saving User, Associate and > the with Model). > If you do not have the Associate to save, just unbind and bind as > hasMany your liked model (the with), and call saveAll... > > hth > > On Jul 2, 6:28 pm, James K <[EMAIL PROTECTED]> wrote: > > > It's best to just make a model for your join table, populate it > > manually and save it separately. There is an "automagic" way to do it > > - which is described in the manual - but it's just as much work and > > not very intuitive. The way the automagic works is you have to add an > > array of Associate keys you want to save into the join table in the > > User data collection (or vice-versa depending on which is the parent > > model). Then when you do user->save, it'll see that collection of keys > > and populate the join table. > > > On Jul 1, 1:44 pm, lirc201 <[EMAIL PROTECTED]> wrote: > > > > Hello All, > > > > I'm stuck and need a jump start here. I have a form that collections > > > User model and Associate model data. User like email, password and > > > Associate like street, city, state, etc... data. I have a HABTM > > > relationship between User and Associate. My question is how to make > > > the linkage work? In this case I'm assuming that both the User and > > > Associate data enter is new. > > > > $this->User->save($this->data); > > > $user_id = $this->User->getLastInsertId(); > > > > at this point do I just this: > > > $this->data['User']['id'] = $user_id; > > > $this->Associate->save($this->data); > > > > Will the join table get popualted? > > > > Thanks, > > > Brian --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
HABTM Relationship and Multiple Models
Hello All, I'm stuck and need a jump start here. I have a form that collections User model and Associate model data. User like email, password and Associate like street, city, state, etc... data. I have a HABTM relationship between User and Associate. My question is how to make the linkage work? In this case I'm assuming that both the User and Associate data enter is new. $this->User->save($this->data); $user_id = $this->User->getLastInsertId(); at this point do I just this: $this->data['User']['id'] = $user_id; $this->Associate->save($this->data); Will the join table get popualted? Thanks, Brian --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
DarkAuth and HABTM Relationship
Just when I thought I have CakePHP figured out, I get a curve ball. I'm trying to integrate DarkAuth into my site. I have a users table, group table both with "id" columns and then a join table (HABTM) with group_id, and user_id columns. I don't understand why Cake believes I need to have a User.group_id column. Query: SELECT `User`.`id`, `User`.`username`, `User`.`passwd`, `User`.`firstname`, `User`.`lastname`, `User`.`email`, `User`.`last_visit`, `User`.`confirmation`, `User`.`active`, `User`.`created`, `User`.`modified`, `Group`.`id`, `Group`.`name`, `Group`.`level`, `Group`.`redirect`, `Group`.`perm_type`, `Group`.`created`, `Group`.`modified` FROM `users` AS `User` LEFT JOIN `groups` AS `Group` ON (`User`.`group_id` = `Group`.`id`) WHERE `user`.`email` = 'emmar0se' AND `user`.`passwd` = 'afb2d1ffbde69e9adce0adb33b092271' AND `user`.`active` = 1 LIMIT 1 Warning: SQL Error: 1054: Unknown column 'User.group_id' in 'on clause' in D:\My Documents\websites\cake\cake\libs\model\datasources \dbo_source.php on line 440 In dark_auth.php the HABTM variable is set to true var $HABTM = true; //set to false if you don use a HABTM group relationship. Brian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Problem with first cake form input name=data[....
I'm having some trouble with my login form. In my thtml file: input('Account/email',array("id" => "email", "class"=>"input"));?> but when I view source: http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---