Code Monkey home page Code Monkey logo

Comments (6)

thbley avatar thbley commented on July 24, 2024

no error (but table tasks_invalid does not exist):

        $pdo = new \PDO('mysql:host=mysql;dbname=tasks;port=3306;charset=utf8mb4;', 'root', 'root');
        $query = 'SELECT id, title, duedate, completed, last_updated_by FROM tasks_invalid WHERE customer_id = ? AND completed = 1';
        $statement = $pdo->prepare($query);
        $statement->execute([123]);
        $result = $statement->fetch();

Query error: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'tasks.tasks_invalid' doesn't exist (42S02).

        $pdo = new \PDO('mysql:host=mysql;dbname=tasks;port=3306;charset=utf8mb4;', 'root', 'root');
        $query = 'SELECT id, title, duedate, completed, last_updated_by FROM tasks_invalid WHERE customer_id = 123 AND completed = 1';
        $statement = $pdo->prepare($query);
        $statement->execute([]);
        $result = $statement->fetch();

from phpstan-dba.

thbley avatar thbley commented on July 24, 2024

Another example:

no error (but table task_invalid does not exist):

        $pdo = new \PDO('mysql:host=mysql;dbname=tasks;port=3306;charset=utf8mb4;', 'root', 'root');
        $ids = implode(',', array_map(intval(...), [1,2,3]));
        $query = sprintf('SELECT id, title, duedate, completed, last_updated_by FROM task_invalid WHERE id IN (%s)', $ids);
        $statement = $pdo->query($query);

Query error: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'tasks.task_invalid' doesn't exist (42S02).

        $pdo = new \PDO('mysql:host=mysql;dbname=tasks;port=3306;charset=utf8mb4;', 'root', 'root');
        $ids = '1,2,3';
        $query = sprintf('SELECT id, title, duedate, completed, last_updated_by FROM task_invalid WHERE id IN (%s)', $ids);
        $statement = $pdo->query($query);

from phpstan-dba.

staabm avatar staabm commented on July 24, 2024

thanks for the report.

please try enabling debugMode and see whether you get a usefull error.

can you reproduce the error in a small repository?

from phpstan-dba.

thbley avatar thbley commented on July 24, 2024
<?php

$pdo = new \PDO('mysql:host=mysql;dbname=tasks;port=3306;charset=utf8mb4;', 'root', 'root');
$ids = implode(',', array_map(intval(...), [1,2,3]));
$query = sprintf('SELECT id, title, duedate, completed, last_updated_by FROM task_invalid WHERE id IN (%s)', $ids);
$statement = $pdo->query($query);
print_r($statement->fetchAll());

$pdo = new \PDO('mysql:host=mysql;dbname=tasks;port=3306;charset=utf8mb4;', 'root', 'root');
$query = sprintf('SELECT id, title, duedate, completed, last_updated_by FROM task_invalid WHERE id IN (%s)', '1,2,3');
$statement = $pdo->query($query);
print_r($statement->fetchAll());

$pdo = new \PDO('mysql:host=mysql;dbname=tasks;port=3306;charset=utf8mb4;', 'root', 'root');
$query = 'SELECT id, title, duedate, completed, last_updated_by FROM tasks_invalid WHERE customer_id = ? AND completed = 1';
$statement = $pdo->prepare($query);
$statement->execute([123]);
$result = $statement->fetch();

$pdo = new \PDO('mysql:host=mysql;dbname=tasks;port=3306;charset=utf8mb4;', 'root', 'root');
$query = 'SELECT id, title, duedate, completed, last_updated_by FROM tasks_invalid WHERE customer_id = 123 AND completed = 1';
$statement = $pdo->prepare($query);
$statement->execute([]);
$result = $statement->fetch();

gives:

 ------ --------------------------------------------------------------------------------------------------------------------- 
  Line   test.php                                                                                                             
 ------ --------------------------------------------------------------------------------------------------------------------- 
  6      Unresolvable Query: Cannot resolve query with variable type: non-falsy-string.                                       
         💡 Consider replacing concatenated string-variables with prepared statements or @phpstandba-inference-placeholder.   
  6      Unresolvable Query: Cannot resolve query with variable type: non-falsy-string.                                       
         💡 Consider replacing concatenated string-variables with prepared statements or @phpstandba-inference-placeholder.   
  11     Query error: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'tasks.task_invalid' doesn't exist (42S02).   
  22     Query error: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'tasks.tasks_invalid' doesn't exist (42S02).  
 ------ --------------------------------------------------------------------------------------------------------------------- 

from phpstan-dba.

thbley avatar thbley commented on July 24, 2024

here is the repository and the pipeline:
https://github.com/thbley/phpstan_dba
https://github.com/thbley/phpstan_dba/actions/runs/5081767755/jobs/9130588776

from phpstan-dba.

thbley avatar thbley commented on July 24, 2024

Closing due to inactivity of project maintainer.

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.