Git Product home page Git Product logo

Comments (9)

staabm avatar staabm commented on June 1, 2024

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.

craigfrancis avatar craigfrancis commented on June 1, 2024

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.

staabm avatar staabm commented on June 1, 2024

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

$queryString .= ' LIMIT 0';

how does your db table look like? maybe it contains a column type, which phpstan-dba not yet supports?

from phpstan-dba.

staabm avatar staabm commented on June 1, 2024

I think I can reproduce now. See similar problems in redaxo/redaxo#4984

Will investigate

from phpstan-dba.

staabm avatar staabm commented on June 1, 2024

with #85 I added a debug mode via RuntimeConfiguration.

when enabled, this might lead to more insights regarding your error

from phpstan-dba.

staabm avatar staabm commented on June 1, 2024

I guess the root cause of your problem was fixed with #91 and #89

please try again using the latest release

from phpstan-dba.

craigfrancis avatar craigfrancis commented on June 1, 2024

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.

staabm avatar staabm commented on June 1, 2024

Does the issue still reproduce or can we close the issue?

from phpstan-dba.

craigfrancis avatar craigfrancis commented on June 1, 2024

Yes, thank you :-)

from phpstan-dba.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.