Comments (6)
There is an easier way (than PDO), you can for instance see how I did this for binary data and nulls. But first, let's analyze the problem:
- string, number, object, array, true, false, null are supported by JSON.
- array, object, true, false are not supported by MySQL.
- decimal, binary, date are not supported by JSON.
- string, number, null are supported by both.
- nulls and strings are handled "correctly".
- PHP implicitly converts strings to numbers when needed.
I'm not saying there can not be a benefit. I think there could be two theoretical benefits in PHP receiving floats and ints (how about decimal type? BC Math?) from MySQL in their corresponding type:
- Avoiding imprecision of string conversion (for floats)
- Performance (no conversion, higher speed)
But do we actually achieve that when we would be receiving floats and ints from PDO? I wonder. Maybe you see other benefits?
from php-crud-api.
Maybe we should bypass PHP and output the MySQL string to javascript (JSON) directly. Still I'm worried about javascript's handling of MySQL types.
from php-crud-api.
I see no solution for longs and decimals, but a conservative change would be to output small to normal sized integer types without quotes.
from php-crud-api.
In my case it would be ok, because I currently need it only for integers.
from php-crud-api.
As you can read here only 53 bits of a 64 bit int are supported. So only 32 bit integers (or smaller) could go without quotes without losing precision.
from php-crud-api.
Fixed in 8616b67, but may cause issues on 8 byte integers (>53 bit) as they cannot be represented in JavaScript. See: 1fce372
from php-crud-api.
Related Issues (20)
- Filter results if joined table has an authorization.recordHandler HOT 3
- HTML Middleware HOT 2
- Update with "where" HOT 8
- "Request Tranformer" middleware HOT 2
- Azure App Service HOT 1
- Add PHP backend to any app project with one command HOT 1
- Any advice on events integration? HOT 2
- Synchronization between local IndexedDB and MySQL Database. HOT 3
- Can the API Support Customized Cache Management for Specific Tables? HOT 9
- Question: Add property on create HOT 3
- Insights on caching with Redis HOT 2
- Using Customization handler to insert app-generated ID HOT 11
- PUT using curl comes back successful but the record is not actually updated HOT 2
- Suggestion to modify response JSON root Key (records) HOT 2
- firebase jwt public key rotation HOT 5
- "Route '' not found" HOT 3
- Additional SQL queries in authorization handlers HOT 2
- Direct usage of PHP CRUD API functions in external PHP Files HOT 8
- Failure on postgres when table name is domains HOT 10
- Returning user uploaded file using custom controller HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-crud-api.