find() PS. I do not ..." />

How to use database functions in Kohana 3 ORM select query?

Or IMHO even beter, try this: $user = ORM::factory('user') ->where('LOWER("email")', '=', DB::expr("LOWER('alice@spam. Com')")) ->find() PS. I do not see any need to create a DB::lower() helper, but that might just be me EDIT: $value = '[email protected]'; $user = ORM::factory('user') ->where('LOWER("email")', '= LOWER', (array) $value) ->find() The query will become something like (havent used ORM in a while) "SELECT users.

Id, users. Email FROM users WHERE LOWER("email") = LOWER ('[email protected]') LIMIT 1". Notice the space, I just updated some of my code to use this since I just figured out this posibility I hope you will be as happy with it as I am.

Or IMHO even beter, try this: $user = ORM::factory('user') ->where('LOWER("email")', '=', DB::expr("LOWER('alice@spam. Com')")) ->find(); PS. I do not see any need to create a DB::lower() helper, but that might just be me... EDIT: $value = '[email protected]'; $user = ORM::factory('user') ->where('LOWER("email")', '= LOWER', (array) $value) ->find(); The query will become something like (havent used ORM in a while) "SELECT users.

Id, users. Email FROM users WHERE LOWER("email") = LOWER ('[email protected]') LIMIT 1". Notice the space, I just updated some of my code to use this since I just figured out this posibility.

I hope you will be as happy with it as I am.

Use of helper was to make it cleaner when escaping the email to compare against. Imagine replacing 'alice@spam. Com' with $_POST'email' and the code becomes uglier (or maybe I don't know how to make it look cleaner).

Could you update your answer with an example on how to do that? – Gerry Jul 2 '10 at 20:24 Done, I do not know if an edit is enough to trigger a notify, so I just post this to be on the save side. – Darsstar Jul 2 '10 at 21:51.

Try this: $user = ORM::factory('user') ->where(DB::expr('lower(email)'), '=', strtolower('alice@spam. Com')) ->find().

Worked perfectly, thank you. – Gerry Jul 1 '10 at 22:19.

I'm not completely happy with the use of a helper but I use it a couple other classes so it's nice to keep the logic in one location. Here is what I'm currently using. Class DB extends Kohana_DB { public static function lower($value) { return DB::expr('lower('.

Database::instance()->quote($value). ')'); } } class Model_User extends Model_Base { public static function find_by_email($email) { $user = ORM::factory('user') ->where(DB::expr('lower(email)'), '=', DB::lower($email)) ->find(); return $user; }.

Postgresql - How to use database functions in Kohana 3 ORM select query - Stack Overflow.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions