Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-726743: [HTAP] LAST QUERY ID - Driver API for PHP/PDO #336

Merged
2 commits merged into from
Sep 19, 2023

Conversation

ghost
Copy link

@ghost ghost commented Sep 16, 2023

sdk issue124
In PDO the query execution is basically on connection level (.e.g using PDO::query https://www.php.net/manual/en/pdo.query.php) and the statement class is for one query returned from PDO::query(). https://www.php.net/manual/en/class.pdostatement.php
So the query id has to be saved on connection level. Especially for the failure case the PDO::query() return false and no statement instance available.

Add driver specific attribute SNOWFLAKE_ATTR_QUERY_ID can be used for PDO::getAttribute() and PDOStatement::getAttribute()
sample code:

    $dbh = new PDO("snowflake:account=<account_name>", "<user>", "<password>");
    $sth = $dbh->query("select 1");
    $qid = $dbh->getAttribute(PDO::SNOWFLAKE_ATTR_QUERY_ID);
    $sqid = $sth->getAttribute(PDO::SNOWFLAKE_ATTR_QUERY_ID);

both qid and sqid will return the same query id of select 1

@ghost ghost self-requested a review as a code owner September 16, 2023 00:43
@ghost ghost requested a review from sfc-gh-igarish September 16, 2023 00:44
Copy link
Collaborator

@sfc-gh-igarish sfc-gh-igarish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ghost ghost merged commit d507b12 into master Sep 19, 2023
14 checks passed
@ghost ghost deleted the SNOW-726743-last-query-id branch September 19, 2023 01:26
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants