Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
working with DECODE(blob field), user login
lighterfluid
February 2014
Hi,
as i can't seem to find a way to handle blob with decode in fuelphp DB Class.
this is my current solution.
$salt = Config::get("security.token_salt");
$query = DB::query("select * from B010User where B010UserCd = '".Input::post("username")."'
and DECODE(B010Passwd, '".$salt."') = '".Input::post("password")."'
and (
B010ActiveSession != '".Session::key("session_id")."'
or B010HeartBeat <= '".date("Y-m-d H:i:s",strtotime(" + 15 minutes "))."') ");
$query->execute();
i would love to know if there's any better way to do this in fuelphp.
Thanks in advance!
WanWizard
February 2014
Start by saying what the problem is. What do you want, and what doesn't work?
In other words, for what is this supposed to be a work-around?
lighterfluid
February 2014
is there any way to handle DECODE() query in DB Class methods?
example:
$query = DB::select("*")->from("users")->where("password",Input::post("password));
above query wont work because the password field is in blob and requires decoding.
WanWizard
February 2014
Accepted Answer
In general, if you need to pass complex constructs to a query, you need to wrap it in a DB::expr() to avoid it being encoded and/or escaped.
Something like:
$query = DB::select("*")->from("users")->where(DB::expr("DECODE(password, ".$salt.")"), Input::post("password));
lighterfluid
February 2014
Thanks!
my approach for login was wrong anyway.
perhaps i should use Auth package.
WanWizard
February 2014
First rule of development: don't code what you can use from someone else...
:-)
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,090
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
262
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
lighterfluid
February 2014
WanWizard
February 2014