2017 © Pedro Peláez
 

library table-creator

Package creating or editing MySQL tables.

image

irap/table-creator

Package creating or editing MySQL tables.

  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 8 % Grown

The README.md

A package to simplify the management of MySQL tables., (*1)

Example Usage

The example below demonstrates how one can use this package to easily create a new MySQL database table:, (*2)

use iRAP\TableCreator\DatabaseField;
use iRAP\TableCreator\TableCreator;
use iRAP\TableCreator\Testing\AbstractTest;

function createTestTable(\mysqli $db)
{
  $tableCreator = new TableCreator($db, "test_table");

  $fields = array(
      DatabaseField::createInt('id', 11, true),
      DatabaseField::createBool('bool_field'),
      DatabaseField::createVarchar('varchar_field', 255),
      DatabaseField::createChar('char_field', 3),
      DatabaseField::createDate('date_field'),
      DatabaseField::createDecimal('decimal_field', 5, 4),
      DatabaseField::createGeometry('geometry_field'),
      DatabaseField::createGeometryCollection('geometry_collection_field'),
      DatabaseField::createLineString('line_string_field'),
      DatabaseField::createLongText('long_text_field'),
      DatabaseField::createMultiLineString('multi_line_string_field'),
      DatabaseField::createMultiPoint('multi_point_field'),
      DatabaseField::createMultiPolygon('multi_polygon_field'),
      DatabaseField::createPoint('point_field'),
      DatabaseField::createPolygon('polygon_field'),
      DatabaseField::createText('text_field'),
      DatabaseField::createTimestamp('timestamp_field')
  );

  $tableCreator->addFields($fields);
  $tableCreator->setPrimaryKey('id');
  $tableCreator->run();
}

Testing

When testing, you may find it easier to just make use of Docker Compose to spin up a temporary database to test against like so:, (*3)

version: "3"

services:
  db:
    image: mariadb:latest
    container_name: db
    ports:
      - "3306:3306"
    volumes:
      - temp-mysql-data:/var/lib/mysql
    environment:
      - MARIADB_ROOT_PASSWORD=thisIsTheTestingPa55w0rd
      - MARIADB_DATABASE=testing

volumes:
  temp-mysql-data:
    driver: local

Then simply create the Settings.php file from the template with the relevant values, and execute the tests with php ./testing/main.php., (*4)

The Versions

03/12 2015

dev-master

9999999-dev

Package creating or editing MySQL tables.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

models mysql mysqli

03/12 2015

1.1.0

1.1.0.0

Package creating or editing MySQL tables.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

models mysql mysqli

22/11 2015

dev-testing

dev-testing

Package creating or editing MySQL tables.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

models mysql mysqli

22/11 2015

1.0.2

1.0.2.0

Package creating or editing MySQL tables.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

models mysql mysqli

16/10 2015

1.0.1

1.0.1.0

Package creating or editing MySQL tables.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

models mysql mysqli

07/08 2015

1.0.0

1.0.0.0

Package creating or editing MySQL tables.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

models mysql mysqli

06/07 2015

dev-test

dev-test http://www.irap.org

Core libraries for PHP 5.3+

  Sources   Download

None

The Requires

  • php >=5.5.0

 

library core