Comments (9)
but it does not support question mark parameters:
hmm question mark placeholders are already supported, see unit test
could you provide a failling test-case?
Also, typo with "containt" (says he with a keyboard who happens to have a nearly broken "t" key, so can you send them my way).
thx for the hint. I realized these typos also right after I sent out the tweet with the typos in it ;-).
already fixed with #63
thanks!
from phpstan-dba.
I'll try to work out what's happening later... I've just run an update, and tested this simple script:
<?php
$pdo = new PDO('mysql:dbname=test;host=localhost', 'test', 'test', [PDO::ATTR_EMULATE_PREPARES => false]);
$statement = $pdo->prepare('SELECT * FROM user WHERE id = ?');
$statement->execute([1]);
?>
And it errors with:
------ ----------------------------------------------------------------------
Line index.php
------ ----------------------------------------------------------------------
5 Query error: You have an error in your SQL syntax; check the manual
that corresponds to your MariaDB server version for the right syntax
to use near '? LIMIT 0' at line 1 (1064).
6 Value 0 is given to execute(), but the query does not contain this
placeholder.
------ ----------------------------------------------------------------------
I've been thrown by the new LIMIT 0
error.
Running the phpunit tests seem to be fine... well, other than tweaking the error messages because I'm using MariaDB, not MySQL... and that also affects the reporting of "phpstan-dba.unknowntable" (lower cased "t", and using a hyphen for the database name as I used the CREATE DATABASE
in schema.sql
.
from phpstan-dba.
Good point,... let me add mariadb to the ci pipeline :-)
update: see #84 .. the only difference I can see atm is the word "Mysql" vs. "MariaDB" in the error messages. everything else seems to be consistent.. which mariadb version do you use?
I've been thrown by the new LIMIT 0 error.
phpstan-dba is using the query from your script, appends LIMIT 0
and sends it to the server to get the necessary result-set type-information. see
how does your db table look like? maybe it contains a column type, which phpstan-dba not yet supports?
from phpstan-dba.
I think I can reproduce now. See similar problems in redaxo/redaxo#4984
Will investigate
from phpstan-dba.
with #85 I added a debug mode via RuntimeConfiguration
.
when enabled, this might lead to more insights regarding your error
from phpstan-dba.
I guess the root cause of your problem was fixed with #91 and #89
please try again using the latest release
from phpstan-dba.
I've created Pull Request 105, which I hope is a quick fix to the first problem:
Value 0 is given to execute(), but the query does not contain this placeholder.
It wasn't fixed with the type changes, and I don't think it relates to it (I'm only using int
, tinytext
, date
, and datetime
fields).
As to your unit test, I'm not sure why $stmt->execute([1])
on line 34, isn't picking up this error.
It looks like a problem in how checkParameterValues works.
As in, $parameters
is set to [':id' => 1]
or [0 => 1]
... $parameterCount
is set to 1 in both cases... and $namedPlaceholders
gets set to [':id']
for the named parameter query, and is empty for the question mark parameter query (as expected).
It's when it get's to the foreach ($parameters loop, where it's checking the parameter keys are in the $namedPlaceholders
array - I don't think can work for question mark parameters.
I'm wondering if that loop should only be run if count($namedPlaceholders) > 0
... I think that should be used, hence the pull request (feel free to delete/edit if you would rather do this in a different way).
As to the SQL error, as it's a different thing, I've opened Issue 106
from phpstan-dba.
Does the issue still reproduce or can we close the issue?
from phpstan-dba.
Yes, thank you :-)
from phpstan-dba.
Related Issues (20)
- Unexpected query error
- Unexpected query error
- Inconsistency for string in query check between Record and Replay HOT 4
- `PDO::FETCH_KEY_PAIR` errors when selecting not exactly 2 columns
- SqlAst: throw when used with pgsql
- Argument expects a literal string, got literal-string HOT 5
- Connection::insert data inference does not use indicated Types HOT 4
- mysqli: error on invalid escaping HOT 5
- Query AST analysis? HOT 2
- Get AST data from `$queryReflection->getResultType` HOT 15
- AST doubts regarding null/not-null HOT 4
- AST: inconsistent behavior with functions and aliases HOT 4
- Analyzing multiple connections HOT 6
- Right vs left join HOT 2
- AST: generic operator support HOT 2
- pgsql support for AST HOT 2
- give up sql based narrowing in case sqlftw cannot parse the query
- pgsql support for uuid type
- Support for (PDO->prepare())->execute() HOT 6
- generic type mysqli_result error with phpstan v1.10.36 and v1.10.37 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 phpstan-dba.