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

PHP PDO port to Deno. #104

Open
suchislife801 opened this issue Jan 21, 2021 · 3 comments
Open

PHP PDO port to Deno. #104

suchislife801 opened this issue Jan 21, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@suchislife801
Copy link

Greetings. I have yet to get your library to work because it ultimately doesn't work with Digital Ocean MySQL 8 Managed databases.

I'm a PHP developer and since PHP is open source I was wondering if you could port PDO to Deno. This would greatly increase Deno popularity and the code is technically already written; PHP is open source.

The real PDO benefits are:

  • security (usable prepared statements)
  • usability (many helper functions to automate routine operations)
  • re-usability (unified API to access multitude of databases, from SQLite to Oracle)

Ideally only the MySQL driver would be ported.

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

@hktr92
Copy link
Contributor

hktr92 commented Jan 28, 2021

Hello, php dev here (apps, not the language).

The main issue with not working with mysql 8 is because mysql 8 has a new password encoding algorithm that broke everything, even PHP. so the issue is NOT in the library, but in the adding this missing support. There's in README.md that it's not supported yet.

PDO is nice because it offers a clean and unified API for using various drivers.

I've been toying a bit around with this library in deno, after working with mysql2 library for nodejs. here's my two cents about this issue and why this library is fine as-is:

  • Deno: db.execute() gives the results as array
  • Node: db.execute() gives array of results AND packet info AND other useless info.

For node-mysql2, I was frustrated by the weird output of that method, so I made a DbResult class with following methods:

export class DbResult<T> {
    constructor (private result: any) {}

    fetchAll<T>(): T[] | null {}
    fetchOne<T>(): T | null {}
    fetchColumn<T>(name?: string): T | null {}
    fetch<T>(): Generator<T> {}

which is more than enough to give you an array of results, a single result or a column value.

If you need the fetch feature, you could simply use generators to achieve the same level of energy.
if you want to prepare queries, you could leverage the decorator pattern to make your own pdo-like api and then call those methods from library.

@lideming lideming added the enhancement New feature or request label May 3, 2021
@suchislife801
Copy link
Author

One year has passed. No updates.

Here is a library I've found that does the job. Can you please implement this?

https://github.com/jeremiah-shaulov/office_spirit_mysql/blob/main/private/auth_plugins.ts

@Schotsl
Copy link
Contributor

Schotsl commented Nov 8, 2022

DO used to work for me. But after updating Deno and switching to the latest version it stopped working :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants