public function query($sql, $data = [])
     {
         $this->_init();

         try {
             $q = $this->db->prepare($sql);
         } catch (PDOException $e) {
             throw new Exception($e->getMessage());
         }

         foreach ($data as $k => $v) {
             $$k = $v;
             $q->bindParam(':' . $k, $$k); # bindParam( ... , PDO::PARAM_INT ...);
         }

         $result = $q->execute();

         if (strpos(trim(strtoupper($sql)), 'SELECT') === 0) {
             $rows = [];
             while($row = $q->fetch()) {
                 $rows[] = $row;
             }
             return $rows;
         }

         return $result;
     }
public function query($sql, $data = [])
     {
         $this->_init();

         try {
             $q = $this->db->prepare($sql);
         } catch (PDOException $e) {
             throw new Exception($e->getMessage());
         }

         foreach ($data as $k => $v) {
             $$k = $v;
             $q->bindParam(':' . $k, $$k); # bindParam( ... , PDO::PARAM_INT ...);
         }

         $result = $q->execute();

         if (strpos(trim(strtoupper($sql)), 'SELECT') === 0) {
             $rows = [];
             while($row = $q->fetch()) {
                 $rows[] = $row;
             }
             return $rows;
         }

         return $result;
     }
public function query ( $ sql , $ data = [ ] ) { $ this -> _init ( ) ; try { $ q = $ this -> db -> prepare ( $ sql ) ; } catch ( PDOException $ e ) { throw new Exception ( $ e -> getMessage ( ) ) ; } foreach ( $ data as $ k => $ v ) { $ $ k = $ v ; $ q -> bindParam ( ':' . $ k , $ $ k ) ; # bindParam( ... , PDO::PARAM_INT ...); } $ result = $ q -> execute ( ) ; if ( strpos ( trim ( strtoupper ( $ sql ) ) , 'SELECT' ) === 0 ) { $ rows = [ ] ; while ( $ row = $ q -> fetch ( ) ) { $ rows [ ] = $ row ; } return $ rows ; } return $ result ; }
Verifies if a condition can return records

@param string $where
Verifies if a condition can return records