Operator

Issue #4 resolved
Former user created an issue

My sql with operator doesn't not working.

$sql = "DELETE FROM 'mytable' WHERE myfield < 10" by example $db->query($sql)->execute() ;

Comments (4)

  1. davidthomas_scorbal

    This is because query() uses filter_var which chokes on the "<". I'd call this a severe bug as it breaks valid SQL, and the comments clearly indicate that this function should execute raw SQL.

  2. nargotik

    Simply change

    public function query($query)
        {
            $this -> _query = filter_var($query, FILTER_SANITIZE_STRING);
            return $this;
        }
    

    to

    public function query($query,$filtered=false)
        {
                    if ($filtered == false {
                         $this -> _query = $query;
                    } else {
                 $this -> _query = filter_var($query, FILTER_SANITIZE_STRING);
                  return $this -> _query;
                    }
        }
    

    Then if you want to filter the query call ->query($sql,true) for filter or ->query($sql) for unfiltered

    Personally I dont like my queries filtered as I check the fields first of setting a query.

  3. Log in to comment