Comments (3)
Hi @david-garcia-garcia , to fetch numeric values as numbers rather than strings simply do this $conn->setAttribute( PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE, true);
Please confirm.
from msphpsql.
@david-garcia-garcia : Does @yitam's recommendation help?
from msphpsql.
First and foremost, I believe the varbinary issue is already fixed by Pull Request #297. Please verify.
Moreover, for numeric types and buffered queries, I don't think the problem exists anymore. Here is my simple script:
$conn->exec("CREATE TABLE testTable (col1 int, col2 float, col3 real)");
$conn->setAttribute( PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE, true);
$stmt = $conn->prepare('INSERT INTO testTable VALUES (5, 0.57, 123.456)');
$stmt->execute();
$stmt = $conn->prepare("select * from testTable", array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL, PDO::SQLSRV_ATTR_CURSOR_SCROLL_TYPE => PDO::SQLSRV_CURSOR_BUFFERED));
if ($stmt->execute()){
$row = $stmt->fetchObject();
var_dump($row);
}
The output I got is
object(stdClass)#2 (3) {
["col1"]=>
int(5)
["col2"]=>
float(0.57)
["col3"]=>
float(123.45600128174)
}
Without PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE
set to true, I got output like this
object(stdClass)#2 (3) {
["col1"]=>
string(1) "5"
["col2"]=>
string(4) "0.57"
["col3"]=>
string(7) "123.456"
}
Therefore, we will close this issue. Please feel free to reopen it if you still experience similar problems.
from msphpsql.
Related Issues (20)
- SEGMENTATION FAULT when using array with keys HOT 3
- Fatal error: Invalid column number in pdo_sqlsrv_stmt_get_col_data HOT 2
- XAMPP on Debian 12 Cant Load Module HOT 7
- PHP 8.0.30 build error: conflicting declaration 'typedef windowsULong_t DWORD' HOT 2
- symbol not found in flat namespace '_SQLAllocHandle' HOT 24
- PECL is missing DLLs for 5.11 HOT 1
- Setting PDO::ATTR_STRINGIFY_FETCHES throws exception HOT 14
- Release beta with support for PHP 8.3 RC 1 HOT 20
- TrustServerCertificate no longer working in v5.11.1 HOT 9
- SQLSTATE[HY000]: [Microsoft][ODBC Driver 18 for SQL Server]Unicode conversion failed HOT 14
- CentOS9 SQL Server 2014 connect failed. Microsoft ODBC Driver 18 for SQL Server : TCP Provider: Error code 0x2746. HOT 6
- Cakephp2 Application takes longer time to fetch data from sql server database resulting php memory error HOT 3
- Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server HOT 1
- Memory leak in Microsoft ODBC Driver 17.10.5 for SQL Server HOT 4
- HY104 Invalid precision value when reusing prepared statement HOT 4
- SQLSTATE[01002] Adaptive Server connection failed (xxx.xx.xx.xxx) HOT 1
- Issue connecting to SQL server from Openshift HOT 1
- Unable to build version 5.12.0beta1 on Windows HOT 2
- New attribute for sql bigint and decimal/numeric types to php int and float types HOT 1
- Performance problem when using params on select query 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 msphpsql.