Welcome Guest, Not a member yet? Register   Sign In
how can I return all users with names that DON'T begin with a letter?
#5

[eluser]got 2 doodle[/eluser]
OK
I tried and tried and tweaked and tweaked and then a new approach
Code:
//This doesn't work
function get_only_number_bands($num,$offset){
   $query = $this->db->where('active = 1');
   $query = $this->db->where('group = 4');
   $query = $this->db->not_like('username', '[A-Z]','after');
   $query = $this->db->get($this->config->item('backendpro_table_prefix').'users',$num,$offset);
   if ($query->num_rows() > 0){return $query->result();}
            
}

This returns the number of bands that start with [0-9]
Code:
function count_where_bandname_starts_num(){
    $query = $this->db->where('active = 1');
       $query = $this->db->where('group = 4');
      $query = $this->db->like('username', '0','after');
       for ($i='1'; $i<='9'; $i++)
                        { $query = $this->db->or_like('username',$i,'after');}
    $query = $this->db->get($this->config->item('backendpro_table_prefix').'users');
    if ($query->num_rows() > 0){return $query->num_rows();}
}

This returns the data from the table
Code:
function get_only_number_bands($num,$offset){
   $query = $this->db->where('active = 1');
   $query = $this->db->where('group = 4');
   $query = $this->db->like('username', '0','after');
       for ($i='1'; $i<='9'; $i++)
                        { $query = $this->db->or_like('username',$i,'after');}
    $query = $this->db->get($this->config->item('backendpro_table_prefix').'users',$num,$offset);
    if ($query->num_rows() > 0){return $query->result();}
            
}

So this seems to work fine, but I would be interested in a cleaner approach. I tried some REGEXP stuff in my mySQL queries but nothing worked, it could also have something to do with my version of mySQL.

doodle


Messages In This Thread
how can I return all users with names that DON'T begin with a letter? - by El Forum - 07-23-2008, 03:58 PM



Theme © iAndrew 2016 - Forum software by © MyBB