if you are on php4 you might need to use findByUser_name

On 10/24/06, roby <[EMAIL PROTECTED]> wrote:
>
> Hi all.
>
> Based on the CakePHP manual tutorial (appendix B), I've found that if I
> changed the table structure for users become like this:
>
> CREATE TABLE users
> (
>   user_id INT AUTO_INCREMENT NOT NULL,
>   user_name VARCHAR(255) NOT NULL,
>   user_password VARCHAR(32) NOT NULL,
>   first_name VARCHAR(255) NOT NULL,
>   last_name VARCHAR(255) NOT NULL,
>   PRIMARY KEY ( user_id )
> );
>
> I got an error in my users_controller.php! The error related to the
> line which seems like this:
>
> $someone =
> $this->User->findByUsername($this->data['User']['username']);
>
> After a few hours (yeah, a few hours if not frustating time) finding
> method "find" in Cake-API manual I can repair the error (but I don't
> get it through manual). My solution become like this:
>
> $someone =
> $this->User->findByUser_name($this->data['User']['username']);
>
> or like this (the other solution):
>
> $someone = $this->User->find(array('user_name' =>
> $this->data['User']['username']));
>
> My questions:
> 1). After all my observation and for I'm being sured, is findByUsername
> related to the field's name in my table? So, if my field's name is
> user___name then the find method become findByUser___name, isn't it?
> 2). If yes, is it a "magic" method that Cake provide?
> 3). If yes, which section in Cake manual and Cake-API manual that
> describe this pretty "frustating" method (at least for someone like me
> who still new with Cake)?
> 4). Is that another solution using query method (Model's)? If yes, how
> to use that method because I confused how to use it? I try like this:
>
> $sql = 'SELECT * FROM users WHERE user_name =
> \''.$this->data['User']['username'].'\'';
> $someone = $this->User->query($sql);
>
> but the login page didn't redirect to another page.
>
> Thanks in advance.
>
>
> >
>


-- 
==
S. DeVore
(the old fart) the advice is free, the lack of crankiness will cost you

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

Reply via email to