Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7081123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:52:51+00:00 2026-05-28T06:52:51+00:00

Using standard php5-pgsql driver it results to me that, at least with the default

  • 0

Using standard php5-pgsql driver it results to me that, at least with the default php settings on ubuntu 10.04, the result values are not mapped to the standard php types. That is

  • postresql::integer => php::int
  • postresql::real => php::float
  • etc

And return the result values being cast to strings. It creates sometimes quite a lot of headache when the locale of system does not coincide with the locale of database etc.

Is it possible somehow to get the appropriate casting in php? If not, any insight on why would very welcome!

EDIT:

The PDO solved the “postresql::integer=>php::int”, but not for ex. “postresql::real=>php::float” it seems because of that PDO uses the native drivers that is pgsql as I understand. The issue with encoding is not a problem in my case, the only need is to map types exactly or at least as close as possible!

$sql = 'SELECT integer_field, numeric_field_10_2 FROM table';
foreach ($dbh->query($sql) as $row) {
    var_dump($row);
}
----------------------------------------
array(4) {
  ["integer_field"]=>int(79)
  ["numeric_field_10_2"]=>string(6) "100.12"
}

Thanks, I.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:52:52+00:00Added an answer on May 28, 2026 at 6:52 am

    This is an issue inherited from the C API, and that from the postgres client protocol. The results are provided as strings in the backend library. It shouldn’t be a problem with compatible encodings, but you’re right, it can be a problem.

    You can use manual casting, or trust the automatics in php, but the real issue is just getting the encoding setup correctly. You can set postgres’ encoding on a per-database or per-cluster basis, I recommend using UTF-8, personally.

    Converting an existing database is quite a hassle, it usually involves a full dump and full import into a new database.

    pg_client_encoding will tell you the current postgres encoding, but won’t help with the php encoding. If you can’t use compatible encoding, maybe it would be worth creating a wrapper that uses iconv to convert the string data.

    Finally, you could use an alternative client library. I believe the PDO postgres library for php handles this better.

    http://us.php.net/manual/en/book.pdo.php

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that submits parameters using standard HTML controls to a PHP
Using standard mysql functions is there a way to write a query that will
In my ASP MVC application I'm using standard SQL (rather that Linq to SQL
I have an application running under WebLogic that is using standard forms authentication. The
I have a site running MVC and Nhibernate (not fluent) using standard session per
I'm using standard BMP images for buttons that come with visual studio. When using
I am developing some websites on my Mac (Standard LAMP setup, with PHP5, Using
I'm not sure if I'm using standard terms, but this is a basic OO
I'm using php 5.2.9 on a production server, and it seems that the exec()
Now I'm using standard phase correlation for image stitching. It give normal results, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.