Forums | Mahara Community

Developers /
Sql function


anonymous profile picture
Account deleted
Posts: 10

18 May 2009, 17:40

Hi

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?

 

Thanks 

Maxime

anonymous profile picture
Account deleted
Posts: 1643

18 May 2009, 19:10

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.

anonymous profile picture
Account deleted
Posts: 10

21 May 2009, 3:26

Thanks

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