Comments (7)
Any updates regarding this matter?
from pdo.
I'll take a look this week. Please bug me if I don' get back to you by Friday.
from pdo.
Can you provide code to duplicate the issue.
from pdo.
Can you provide code to duplicate the issue.
Sure, but it is nothing special:
$result = $this->database
->select()
->from('table-name')
->limit(5)
->execute();
Results in:
SERVER_ERROR 500 - SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''5'' at line 1
Probably because executing the statement while passing parameters will treat them as:
@param array $params [optional]
* An array of values with as many elements as there are bound
* parameters in the SQL statement being executed.
* All values are treated as PDO::PARAM_STR.
While the limit should be an integer.
from pdo.
I am not sure how you did this, I cannot duplicate the issue with MariaDB 10.2. Do you have a specific database configuration that is causing this error? I am going to need a lot more info about how this is happening.
$db = new Database(
'mysql:host=127.0.0.1;dbname=testing;charset=utf8mb4',
'root',
null
);
var_dump(
$db->select(['id'])
->from('test')
->limit(new Limit(10))
->__toString()
);
// string(30) "SELECT id FROM tbluser LIMIT ?"
$result = $db->select(['id'])
->from('test')
->limit(new Limit(10))
->execute();
var_dump($result->fetchAll());
/*
array(10) {
[0]=>
array(1) {
["id"]=>
int(31)
}
[1]=>
array(1) {
["id"]=>
int(90090)
}
[2]=>
array(1) {
["id"]=>
int(1)
}
[3]=>
array(1) {
["id"]=>
int(11)
}
[4]=>
array(1) {
["id"]=>
int(21)
}
[5]=>
array(1) {
["id"]=>
int(41)
}
[6]=>
array(1) {
["id"]=>
int(51)
}
[7]=>
array(1) {
["id"]=>
int(61)
}
[8]=>
array(1) {
["id"]=>
int(71)
}
[9]=>
array(1) {
["id"]=>
int(81)
}
}
*/
from pdo.
I figured it out... somehow you've managed to enable PDO::ATTR_EMULATE_PREPARES
.
from pdo.
You can try this patch, I am not sure this wont cause other interesting side effects with decimal or enum types.
diff --git a/src/AbstractStatement.php b/src/AbstractStatement.php
index e644774..e4b5d64 100644
--- a/src/AbstractStatement.php
+++ b/src/AbstractStatement.php
@@ -33,7 +33,16 @@ abstract class AbstractStatement implements StatementInterface
{
$stmt = $this->dbh->prepare($this->__toString());
if ($stmt !== false) {
- $stmt->execute($this->getValues());
+ foreach ($this->getValues() as $i => $value) {
+ $type = PDO::PARAM_STR;
+ if (is_int($value)) {
+ $type = PDO::PARAM_INT;
+ }
+
+ $stmt->bindParam($i + 1, $value, $type);
+ }
+
+ $stmt->execute();
}
return $stmt;
from pdo.
Related Issues (20)
- Email and domain not working? HOT 1
- MD5 of column value in where clause HOT 1
- Error when setting charset HOT 1
- Join not working properly HOT 4
- Uncaught TypeError: Argument 1 passed to FaaPz\PDO\DatabaseException::__construct() must be of the type string, null given HOT 15
- Use MySQL function and column as conditional value HOT 6
- Invalid value for insert statement when trying to insert NULL HOT 4
- Insert execute no longer return new id HOT 1
- How to use Clasule RAW HOT 2
- Creating the WHERE clause HOT 1
- Inserts are duplicated HOT 1
- Error in docs of update HOT 1
- Insert Many Table HOT 1
- Help needed on insert statement HOT 14
- Update about text "Just another PDO database library" HOT 1
- lastinsertid removed? HOT 2
- README not up to date HOT 4
- orderBy is not rendered when optional direction is omitted HOT 2
- Between condition with parentheses lead to strange state HOT 1
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 pdo.