terryds Posted October 12, 2013 Share Posted October 12, 2013 I found this in someone's code $query = $this->db->query($string, PDO::FETCH_BOTH); The query statement there is using PDO::FETCH_BOTH... What i know that we use PDO::FETCH_BOTH in fetch statement only.... Can you tell me the use of it? Does it fetch the queried string directly ? But, i do a test, then i see nothing's special try { $sql = 'SELECT * from author WHERE 1'; $s = $pdo->query($sql, PDO::FETCH_BOTH); } catch (PDOException $e) { echo "Error"; exit(); } var_dump($s); It shows up like this : object(PDOStatement)[3]public 'queryString' => string 'SELECT * from author WHERE 1' (length=28) So, what's the deal of using PDO::FETCH_BOTH in a query statement ? Link to comment Share on other sites More sharing options...
Ingolme Posted October 12, 2013 Share Posted October 12, 2013 It seems to be a mistake in the person's code. Try removing the PDO::FETCH_BOTH to see if the result is the same. Link to comment Share on other sites More sharing options...
terryds Posted October 12, 2013 Author Share Posted October 12, 2013 (edited) That's the same result ! i've tested it ! Yay ! I get the deal! The PDO::FETCH_BOTH sets the pdo fetch method... so when we fetch the queried sql, it will use PDO::FETCH_BOTH Edited October 12, 2013 by terryds Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now