Welcome Guest, Not a member yet? Register   Sign In
using validation_errors() with database
#5

[eluser]Fandy[/eluser]
dh,

i use this code to check username exist in database.
but, when i run my code.It only,. check one record in database.

Please help me..

This my controller

Code:
....
function username_check($str){
    $data['user'] = $this->formModel->getData();
            
    foreach($data['user'] as $usr){
        if($str == $usr->username){
        $this->validation->set_message('username_check','Username already exist');
            }else{
            return TRUE;
            }
        }
....

This my model
Code:
<?php
    class FormModel extends Model{
    
        function __construct(){
            parent::Model();
        }
        
        function getData(){
            return $this->db->query('SELECT username FROM user');
        }
    }

?>


Messages In This Thread
using validation_errors() with database - by El Forum - 10-16-2010, 06:10 AM
using validation_errors() with database - by El Forum - 10-16-2010, 06:52 AM
using validation_errors() with database - by El Forum - 10-16-2010, 07:11 AM
using validation_errors() with database - by El Forum - 10-17-2010, 09:46 AM
using validation_errors() with database - by El Forum - 11-04-2010, 09:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB