Forums | Mahara Community

Developers /
Sql function

Maxime Rigo's profile picture
Posts: 10

18 May 2009, 5:40 PM


i'm trying to get id'user when a query is made with the username

i use this :  $sql = get_field('usr', 'id','username',$slev );

but it's seems to be case sensitive for the username.  does a function exist to do this but case insensitive?




Nigel's profile picture
Posts: 1643

18 May 2009, 7:10 PM

Hi. Use the SQL LOWER() function (mahara does this in the places it needs to):

get_field('usr', 'id', 'LOWER(username)', $slev);

If it's the current user you need it for, you can just use the $USER object.

Maxime Rigo's profile picture
Posts: 10

21 May 2009, 3:26 AM


finely LOWER(username) used in get_field() return an error: LOWER(username) is used as a column name 

so i used get_field_sql()  and it works

3 results