PHP Classes

Update Environment: Update database and files from a remote server

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   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
Description 

Author

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
Winner


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: 36
All time rank: 1954127 in Brazil Brazil
Week rank: 192 Up14 in Brazil Brazil Up
Innovation award
Innovation award
Nominee: 2x

Winner: 1x

Example

<?php
// 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, '');


require
'Product.class.php';
require
'Customer.class.php';
require
'../class/DataBase.class.php';
require
'../class/Download.class.php';
require
'../class/RecordFilter.class.php';
require
'../class/UpdateDataBase.class.php';


$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(
       
'class'=>'Product',
       
'constPath'=>'DIR_FILE',
       
'thumb' =>array('t1_','t2_'),
       
'columnOrder' =>'dateinsert'
   
)
);

//array with the tables that should not be updated
$aExcludeTable = array(
   
'brasil_cidade',
   
'brasil_estado'
);



$urlRemote = 'http://www.yoursite.com.br/';
$updateDb = new UpdateDataBase($urlRemote,$aModelOfTable);
$updateDb->update($aExcludeTable);

$download = new Download($aModelOfTable,$urlRemote);
$download->getRecords($aExcludeTable);
$download->downloadNow();

exit;


Details

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 (12)  
File Role Description
Files folder imageclass (4 files)
Files folder imagedownloaded (4 files)
Files folder imageexample (3 files)
Accessible without login Plain text file README.md Data Auxiliary data

  Files folder image Files (12)  /  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 (12)  /  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 (12)  /  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

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:802
This week:0
All time:4,279
This week:455Up