aksu
aksu

Reputation: 5235

Datatype integer?

This is driving me crazy. For some weird reason, pdo's fetch style parameter's datatype is integer? It can't be integer, its more like a string without quotes around it.. Plus there is no numbers in it. I found it, when i was trying to make pdo function library, but it's not so important to this. Check this out:

echo gettype(PDO::FETCH_ASSOC); // returns 'integer'

What is this all about??

Upvotes: 0

Views: 128

Answers (2)

Nouphal.M
Nouphal.M

Reputation: 6344

As per the PHP docs the fetch_style parameter is of type int, As per PHP docs

  fetch_style Controls how the next row will be returned to the caller. This value must be
 one of the PDO::FETCH_* constants, defaulting to value of PDO::ATTR_DEFAULT_FETCH_MODE 
(which defaults to PDO::FETCH_BOTH)

where PDO::FETCH_ASSOC is a constant whose value is 2. And the gettype function returns the type of variable.

Upvotes: 2

René Höhle
René Höhle

Reputation: 27295

So you have edit your Question this is not a problem. PDO::FETCH_ASSOC is a constant in the PDO Class.

http://www.php.net/manual/en/pdo.constants.php

Here you can see all constants and you can see that the PDO:FETCH_ASSOC is an integer. This is only that you can use a defined value.

Upvotes: 1

Related Questions