slam/mysql-php

This package is abandoned and no longer maintained. No replacement package was suggested.

PHP version of mysql cli that comes with MySQL

Maintainers

👁 Slam

Package info

github.com/Slamdunk/mysql-php

pkg:composer/slam/mysql-php

Statistics

Installs: 24 880

Dependents: 0

Suggesters: 0

Stars: 6

Open Issues: 4

v1.1.0 2023-01-04 10:23 UTC

Requires

  • php: ~8.1.0 || ~8.2.0
  • ext-mysqli: *

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 74b808be215e5e82f0a7d5153c90e62859858e0e

  • Filippo Tessarotto <zoeslam.woop@gmail.com>

mysql


README

👁 Latest Stable Version
👁 Downloads
👁 Integrate
👁 Code Coverage

PHP light version of mysql cli that comes with MySQL.

Why

  1. You are inside a PHP only environment, like a PHP Docker image
  2. You need to import a large mysql dump
  3. You don't have access to the native mysql client

Performance

Speed is exactly the same of the original mysql binary thanks to streams usage.

Supported formats

Usage

The library provides two usages, the binary and the \SlamMysql\Mysql class.

From CLI

$ ./mysql -h
Usage: mysql [OPTIONS]
 --host Connect to host [Default: INI mysqli.default_host]
 --port Port number [Default: INI mysqli.default_port]
 --username User for login [Default: INI mysqli.default_user]
 --password Password to use [Default: INI mysqli.default_pw]
 --database Database to use [Default: empty]
 --socket The socket file [Default: INI mysqli.default_socket]

$ printf "CREATE DATABASE foobar;\nSHOW DATABASES;" | ./mysql
information_schema
foobar
mysql
performance_schema
sys

$ ./mysql --database foobar < foobar_huge_dump.sql

From PHP

$mysql = new \SlamMysql\Mysql('localhost', 'root', 'pwd', 'my_database', 3306, '/socket');
$return = $mysql->run(\STDIN, \STDOUT, \STDERR);
exit((int) (true !== $return));

\SlamMysql\Mysql::run accepts any type of resource consumable by fgets/fwrite functions.

Related projects

  1. ifsnop/mysqldump-php: mysqldump binary port in pure PHP