Giter Club home page Giter Club logo

Comments (6)

parsibox avatar parsibox commented on May 24, 2024

you have $query_id->getStatement();
please change this

from pdooci.

taq avatar taq commented on May 24, 2024

I'm missing your point. PHP PDO::query accepts a SQL string and returns a statement:

https://www.php.net/manual/en/pdo.query.php

Parameters
query
The SQL statement to prepare and execute.

Return Values
Returns a PDOStatement object or false on failure.

That's exactly what PDO::query does here. They are compatible. What is wrong? It's not supposed to return the query string.

from pdooci.

parsibox avatar parsibox commented on May 24, 2024

in pdo we can get the query string with this command :

$query_id->queryString;

in your code we can get string we this code :

$query_id->getStatement();

please change this

from pdooci.

taq avatar taq commented on May 24, 2024

Not really.

Taliking about the original PDO, we can get the query string from the statement using

$statement->queryString;

Check https://www.php.net/manual/en/class.pdostatement.php :

class PDOStatement implements Traversable {
/* Properties */
readonly string $queryString;

So, if you use

$query_id->getStatement();

as said, it will return the statement, not the SQL string, which is correct.

To the get the SQL string, now it's a new implementation, because we don't have the $queryString property on the Statement class and it will need to be implemented as a readonly property and stored on the Statement constructor.

Is that correct? But I wouldn't use readonly properties, because it's only available on PHP 8.1 and I don't want to break compatibility with older versions.

from pdooci.

parsibox avatar parsibox commented on May 24, 2024

dear
if possible just change $query_id->getStatement(); to $query_id->queryString;

from pdooci.

taq avatar taq commented on May 24, 2024

No, it's not possible, it will not work, did you test it? You can write code and test by hand. You can write code and test via the test suite. Did you run the test suite to check it?

The queryString property is a read only property, as I mentioned before. If we try to store it on the Statement constructor, we'll get an error. I just tested it here:

PDOException: SQLSTATE[HY000]: General error: property queryString is read only

So, with the current code we can access it (it's inherited from PDO::Statement) but we can't change it. Check this:

mockery/mockery#575 (comment)

The PDO::Statement class does not have a constructor to call with the SQL string. So, the only way to make this works is removing the PDO::Statement inheritance from the current Statement class, but I'm not sure it will miss some methods there. It worked removing, but we need to make sure everything is working.

I just created a new branch called query_string, could you please use the code there and make sure it works? I don't even use PHP or Oracle anymore. Just installed it here to run the tests.

If you test it, run the test suite, please.

But I think it will be more dangerous to remove the inheritance than to avoid using queryString.

from pdooci.

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.