# ResultSet always returns string (Pgsql adapter)

**URL:** <https://discourse.laminas.dev/t/resultset-always-returns-string-pgsql-adapter/530>\
**Category:** Components & MVC\
**Tags:** zend-db\
**Created:** [March 15, 2018, 9:34am UTC](https://discourse.laminas.dev/t/resultset-always-returns-string-pgsql-adapter/530 "2018-03-15T09:34:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbelien](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/jbelien/32/251_2.png) [@jbelien](https://discourse.laminas.dev/u/jbelien)\
**Post date:** [March 15, 2018, 9:34am UTC](https://discourse.laminas.dev/t/resultset-always-returns-string-pgsql-adapter/530/1 "2018-03-15T09:34:31Z")

</div>

Hello everyone,

I started to use `zend-db` to query a PostgreSQL database ; it obviously works fine but I’m a bit confused with the `ResultSet` interface.  
No matter what datatype my columns are in the database, it always returns a “string”.

Here is an example of my query :

```auto
$sql = new Sql($adapter, $config['postgresql']['table']);

$select = $sql->select();
$select->columns([
    'status',
    'count' => new Expression('COUNT(*)'),
]);
$select->group([
    'status',
]);

$qsz = $sql->buildSqlString($select);
$statitics = $adapter->query($qsz, $adapter::QUERY_MODE_EXECUTE);

```

No matter what I do, I receive `status` and `count` as **string** but they are both **integer**!

I guess I missed something and would need some help to figure out how to receive it with the correct datatype.

Thanks a lot 🙂

---

<div class="post-metadata">

**Author:** ![lowtower](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/lowtower/32/98_2.png) [@lowtower](https://discourse.laminas.dev/u/lowtower)\
**Post date:** [March 15, 2018, 10:06am UTC](https://discourse.laminas.dev/t/resultset-always-returns-string-pgsql-adapter/530/2 "2018-03-15T10:06:05Z")

</div>

Hello @jbelien,

try configuring the [pdo adapter](https://secure.php.net/manual/en/pdo.setattribute.php).  
Set `PDO::ATTR_STRINGIFY_FETCHES` to `FALSE`.

e.g. for sqlite:

```php
return [
    'db' => [
        'driver' => 'Pdo',
        'dsn' => 'sqlite:./database.sqlite',
        'driver_options' => [
            PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'',
            PDO::ATTR_STRINGIFY_FETCHES => FALSE,
        ],
    ],
];

```

---

<div class="post-metadata">

**Author:** ![jbelien](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/jbelien/32/251_2.png) [@jbelien](https://discourse.laminas.dev/u/jbelien)\
**Post date:** [March 15, 2018, 11:40am UTC](https://discourse.laminas.dev/t/resultset-always-returns-string-pgsql-adapter/530/3 "2018-03-15T11:40:23Z")

</div>

Hello @lowtower,

I was using `Pgsql` adapter ; I switched to `Pdo_Pgsql` adapter and the “issue” is fixed.  
So I guess, there is an option I didn’t find for `Pgsql` adapter (or maybe a bug with that adapter).

I’ll keep using `Pdo_Pgsql` adapter and see if everything works as excepted 🙂

Thanks a lot for the tip !
