2017 © Pedro Peláez
 

library dbcmd

Wrappter to build and execute management commands against a DB

image

hgg/dbcmd

Wrappter to build and execute management commands against a DB

  • Friday, November 7, 2014
  • by hglattergotz
  • Repository
  • 1 Watchers
  • 0 Stars
  • 24 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Generic API for running console commands against a DB (previously hgg/dbbackup) from within a PHP application., (*1)

Build Status, (*2)

Warning: The commands are constructed containing the password in order to run non-interactive. This can be considered to be insecure., (*3)

Operations include:, (*4)

  • Create a database
  • Drop a database
  • Dump a table to a dump file
  • Dump a database to a dump file
  • Load a table from a dump file

Installation

Using Composer:, (*5)

{
    "require": {
        "hgg/dbcmd": "dev-master"
    }
}

Download source and manually add to project:, (*6)

  • Get the zip file here

Supported Databases:

  • MySql

Pull Requests for additional database engines welcome!, (*7)

Usage

Dump entire database

use HGG\DbCmd\CmdBuilder\MySql;
use HGG\DbCmd\DbCmd;

try
{
    $output = '';
    $cmd = new DbCmd(new MySql());
    $cmd->dumpDatabase('username', 'password', 'localhost', 'database',
        'dumpFile', array(), &$output);

    // log $output
}
catch (\Exception $e)
{
    // deal with failure
}

Dump specific tables in a database

use HGG\DbCmd\CmdBuilder\MySql;
use HGG\DbCmd\DbCmd;

try
{
    $output = '';
    $cmd = new DbCmd(new MySql());
    $cmd->dumpTables('username', 'password', 'localhost', 'database',
        array('table1', 'table2'), 'dumpFile', array(), &$output);

    // log $output
}
catch (\Exception $e)
{
    // deal with failure
}

Restore form a dump file

use HGG\DbCmd\CmdBuilder\MySql;
use HGG\DbCmd\DbCmd;

try
{
    $output = '';
    $cmd = new DbCmd(new MySql());
    $cmd->load('username', 'password', 'localhost', 'database',
        'dumpFile', array(), &$output);

    // log $output
}
catch (\Exception $e)
{
    // deal with failure
}

The Versions

07/11 2014

dev-master

9999999-dev http://github.com/hglattergotz/dbcmd

Wrappter to build and execute management commands against a DB

  Sources   Download

MIT

The Requires

 

mysql backup dump

07/11 2014

v0.0.1

0.0.1.0 http://github.com/hglattergotz/dbcmd

Wrappter to build and execute management commands against a DB

  Sources   Download

MIT

The Requires

 

mysql backup dump