![]() |
simple_query question - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: simple_query question (/showthread.php?tid=5252) Pages:
1
2
|
simple_query question - El Forum - 01-14-2008 [eluser]williamparry[/eluser] Hi, I am trying to run a query where the database checks to see if an email address has already been registered. What do I need to do here? Code: $this->db->simple_query("SELECT id FROM users WHERE emailAddress = '$emailAddress'"); For it to return true or false or the number of rows? Do I wrap that into a variable and then use rows()? simple_query question - El Forum - 01-14-2008 [eluser]xwero[/eluser] Code: $query = $this->db->query("SELECT count(*) tel FROM users WHERE emailAddress = ?",array($emailAddress)); simple_query question - El Forum - 01-14-2008 [eluser]williamparry[/eluser] Great thanks! So var tel is the count of * ? I now get: "Unable to access an error message corresponding to your field name." Code: $rules['emailAddress'] = "required|valid_email|callback_checkEmailAddress"; Do I add another: Code: $fields['emailAddress'] = 'Email Address'; simple_query question - El Forum - 01-14-2008 [eluser]xwero[/eluser] tel is an alias of the count(*) function so you won't have to do $row->count(*), i don't think it will work. To make a callback function you have to define the message. Code: function _checkEmailAddress($str) // start with an underscore to make function invisible for the routing simple_query question - El Forum - 01-14-2008 [eluser]Derek Allard[/eluser] The Active Record class in the SVN (link) has a count_all_records() in it. Code: $this->db->where('emailAddress', $emailAddress); simple_query question - El Forum - 01-15-2008 [eluser]williamparry[/eluser] Thanks for the replies. I updated the active record class with that file and it gave: A PHP Error was encountered Severity: Notice Message: Undefined property: CI_DB_mysql_driver::$_count_string Filename: database/DB_active_rec.php Line Number: 752 simple_query question - El Forum - 01-15-2008 [eluser]Seppo[/eluser] Did you update all your files to SVN revision? I think you are missing, in this case, MySQL driver new version. simple_query question - El Forum - 01-15-2008 [eluser]Derek Allard[/eluser] Yeah, Seppo is correct, but its my fault... I should have told you. Assuming you're using mysql, grab this. simple_query question - El Forum - 01-16-2008 [eluser]williamparry[/eluser] Where can I download all SVN files? I'm getting: Fatal error: Class 'CI_DB' not found in DB_driver.php on line 31 simple_query question - El Forum - 01-16-2008 [eluser]Pascal Kriete[/eluser] Follow the instructions found here. |