Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
working with DECODE(blob field), user login
  • 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!
  • 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?
  • 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.
  • HarroHarro
    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));
  • Thanks! 

     my approach for login was wrong anyway.
     perhaps i should use Auth package.


  • First rule of development: don't code what you can use from someone else... :-)

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion