mysql icon indicating copy to clipboard operation
mysql copied to clipboard

PHP PDO port to Deno.

Open suchislife801 opened this issue 4 years ago • 3 comments

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

suchislife801 avatar Jan 21 '21 22:01 suchislife801

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.

hktr92 avatar Jan 28 '21 14:01 hktr92

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

suchislife801 avatar Jan 18 '22 14:01 suchislife801

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

Schotsl avatar Nov 08 '22 21:11 Schotsl