PHP Classes

Update Environment: Update database and files from a remote server

Recommend this page to a friend!
  Info   View files Example   View files View files (12)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 802 All time: 4,279 This week: 455Up
Version License PHP version Categories
update-enviroment 2BSD License5.3PHP 5, Databases, Systems administration


This class can update database and files from a remote server.

The main class can connect to a remote MySQL database using PDO and retrieve the list of tables to compare with the locale MySQL database synchronize the new tables that need to be created or the existing tables that need to be updated.

Another class can also synchronize files referenced by specific database table records as they contain data not stored in the database itself.

A list of specific tables may be intentionally excluded from the synchronization process.

Innovation Award
PHP Programming Innovation award winner
September 2012

Prize: One yearly subscription to the PHP Solutions magazine
Some database applications manage content information that can be large. Usually those application store large content in separate files and just keep a reference in the database to the data files.

In this situation, if you want to backup or synchronize the database contents you also need to transfer the data files.

This class provides a solution that can synchronize both the MySQL database data and any separate files associated to given table fields.

Manuel Lemos
Picture of Alexsandro Souza
  Performance   Level  
Name: Alexsandro Souza <contact>
Classes: 2 packages by
Country: Brazil Brazil
Age: 35
All time rank: 1953127 in Brazil Brazil
Week rank: 311 Up17 in Brazil Brazil Up
Innovation award
Innovation award
Nominee: 2x

Winner: 1x


// remote access db
define(REMOTE_DB_TIPO, 'mysql');
define(REMOTE_DB_PORT, '');
define(REMOTE_DB_NAME, 'blowtex');
define(REMOTE_DB_USER, 'root');
define(REMOTE_DB_PASS, 'salve');
define(REMOTE_DB_HOST, 'salveweb');

//local access db
define(LOCAL_DB_TIPO, 'mysql');
define(LOCAL_DB_PORT, '');
define(LOCAL_DB_NAME, 'test');
define(LOCAL_DB_USER, 'root');
define(LOCAL_DB_PASS, '');
define(LOCAL_DB_HOST, 'localhost');

define(RECORD_LIMIT, 50);
define(PATH_COMPLEMENT, '');


$aModelOfTable = array(
'customer' => array( //name table
'class'=>'Customer', //class model of table
'constPath'=>'DIR_FILE', // constant of class model with the path of the files
'thumb' =>array('t1_','t2_'), //abbreviation of the thumb of the file
'columnOrder' =>'id', //column used to sort the results of queries
'columnDownload' =>'file'//column that usually saves the files to be downloaded, it does not contain this column in the table, the component filters all columns by searching for valid, current gif, jpg, png and pdf
'product' => array(
'thumb' =>array('t1_','t2_'),
'columnOrder' =>'dateinsert'

//array with the tables that should not be updated
$aExcludeTable = array(

$urlRemote = '';
$updateDb = new UpdateDataBase($urlRemote,$aModelOfTable);

$download = new Download($aModelOfTable,$urlRemote);



Update--Environment-QA ====================== Pacote que permite atualizar seu ambiente de desenvolvinmento/homologação apartir do ambiente de produção. Esse componente atualiza seu ambiente com os dados dinâmicos do seu ambiente espelho, ou seja, apartir dos seus dados de acesso dos bancos de dados local e espelho é possivel atualizar automaticamente seu banco local e baixar os arquivos como imagem, pdf e doc, inerentes aos registros do banco, de forma a manter a mesma estrutura do ambiente espelho. Com esse componente combinado ao uso do GIT, torna muito fácil manter um ambiente de homologação fiel ao de produção

  Files folder image Files  
File Role Description
Files folder imageclass (4 files)
Files folder imagedownloaded (4 files)
Files folder imageexample (3 files)
Accessible without login Plain text file Data Auxiliary data

  Files folder image Files  /  class  
File Role Description
  Plain text file DataBase.class.php Class Class source
  Plain text file Download.class.php Class Class source
  Plain text file RecordFilter.class.php Class Class source
  Plain text file UpdateDataBase.class.php Class Class source

  Files folder image Files  /  downloaded  
File Role Description
  Accessible without login Image file pendrive.gif Photo Photograph
  Accessible without login Plain text file test.pdf Data Auxiliary data
  Accessible without login Plain text file test2.pdf Data Auxiliary data
  Accessible without login Image file testeimage.png Photo Photograph

  Files folder image Files  /  example  
File Role Description
  Accessible without login Plain text file Customer.class.php Aux. Example script
  Accessible without login Plain text file index.php Example Example script
  Accessible without login Plain text file Product.class.php Aux. Example script

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:4,279
This week:455Up