Code Monkey home page Code Monkey logo

dbsync's Introduction

dbsync

PHP Mysql Database Syncing Class

This class allows you to be able to set php files to establish what database changes need to happen to your local database copy. Primary use is for groups of people who use version control systems(like git) to maintain projects, but want keep a local database copy for testing.

Installation and Setup

Settings

  1. Open up dbsync.php file:
    1. Set database variable to desired database
    2. Set other class variables if you need to change them from current value - recommended to leave as is

Files Structure

  1. Unless changed all database files are in dbtables folder
  2. _tables.php is your primary table for setting all the database tables you need.
    1. In the _tables.php file is a $tables assoc array that contains table(key) and a value(array)
      1. Example:
        $_tables = array(
            'table1' => array('notes' => 'Here are some notes about this table'),
            'table2' => array(),
            'table3' => array()
        );
    2. Each table may have a notes variable in array if desired to set notes for that table
      Ex: 'table' => array('notes' => 'Here are some notes about this table')
  3. Dbsync runs through each key in $_tables array and looks for the correspoding ${key}.php file.
    Ex: If key = 'table1' dbsync will look for table1.php files for that tables columns.
  4. In each tables file there should be a ${table}_columns array
    Ex: Inside the table1.php file should be a $table1_columns array

Column Settings

  1. In each table file the main array will consist of the key(column name) and value(list of possible column attributes)
  2. Ex:
    '{columnname}' => array(
        'type' => 'INT', // Type of column - NOT case sensative anymore
        'constraint' => 11, // Optional - Constraint for type - Ex: INT(11) or DECIMAL(10,2)
        'default' => '{defaultvalue}', // Optional - Default value if inset is null or non existant
        'primary' => false, // Optional - Default is false - Indicates whether or not column is a primary
        'index' => false, // Optional - Default is false - Indicates whether or not column is indexed
        'unique' => false, // Optional - Default is false - Indicates whether or not column is a unique index
        'auto_increment' => false, // Optional - Default is false - Indicates whether or not column is auto_incremented to next number
        'null' => false // Optional - Default is false - Indicates whether or not column can be null
        'on_update_time' => false // Optional - Default is false - Whether or not to update on row modification
        'extra' => {attribute value} // Optional - BINARY, UNSIGNED or UNSIGNED ZEROFILL
    )

dbsync's People

Contributors

brianvoe avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

kntmicheal

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.