microsoft / microsoft/msphpsql

New attribute for sql bigint and decimal/numeric types to php int and float types

Open
#1,498 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: data-types feature request P3
Dominant language
PHP
Stars
1.9k
Forks
385
Avg merge
3d 22h
Merged PRs (30d)
1

Description

Is your feature request related to a problem? Please describe.

We are changing our pdo driver from pdo_dblib to pdo_sqlsrv and have issues with bigints and decimals being cast to strings. We pass these values straight to our frontend which does some small calcs for display (totals etc...). I have read through the issues related to this area such as #291 and absolutely agree that by default these types need to be strings to preserve precision. However, a) bigint is the same size as the php int type on most systems b) as mentioned, to do any sort of operation on these values they must be converted to php floats anyway. There is no built-in way to arithmetically handle decimals as decimals in PHP so I don't see the harm in (optionally) always converting these to floats.

Describe the solution you'd like

One or two attributes added to allow default types of int and float for bigint and decimal/numeric types.

Describe alternatives you've considered

Currently I am using a custom version of pdo_sqlsrv with a modified sql_type_to_php_type method.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the sql_type_to_php_type method mentioned in the issue and read how bigint and decimal/numeric values are currently mapped. Determine where optional attributes would be defined and tested, then confirm that the requested opt-in mappings produce PHP int and float values while preserving the existing default behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, sql
Domain
database
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.