postgresql ?????? PHP? mysql ?????? ?? ???? ?????.
Jul 29, 2016 am 08:37 AM1. DbBak? ???????? ??? ??? ??($connectid)? ??? ????($backupDir)?? ? ?? ??? ????? ???.
require_once('DbBak.php')
require_once('TableBak.php');
$connectid = mysql_connect('localhost','root','123456')
$backupDir = 'data'
$DbBak($ connectid,$backupDir) ; ?
2. ?? ?? ??? ??????? ??? ? ?? ?? ??? ??? ???? ????? ??? ?? ????.
2.1 mybbs ?????? ?? ???? ????? ??? ?????.
$DbBak->backupDb('mybbs')
2.2 ??, ???, ???? ????? ?? mybbs ?????? friendlist ???? 1?? ??? ??? ? ????:
$DbBak- >backupDb('mybbs',array('board','face','friendsite')); >2.3 ?? ??? ? ??? ???? ????? ??:
$DbBak->backupDb(' mybbs','board')
3. ? ?? ?? 2.1, 2.1 ? 2.3? ?? ???? ??? ???? backupDb? RestoreDb? ???? ??? ??? ??? ? ????.
$DbBak->restoreDb('mybbs')
SQL ??
$DbBak ->restoreDb('mybbs',array('board','face','friendsite'))
PHP ??
$DbBak->restoreDb('mybbs','board');???>PHP ??
require_once('TableBak.php');?
class DbBak {?
var $ _mysql_link_id;
var $_tableList;
function DbBak($_mysql_link_id,$dataDir) _string($dataDir) ) || strlen($dataDir)==0) && die('error:$datadir? ???? ????.')
!is_dir( $dataDir) && mkdir($dataDir);
$this-> ; _datadir = $ datadir;
$ this- & gt; $ tablename = null)
{ ((! IS_STRING ($ dbName)) || strlen($dbName)==0 ) && die('$dbName? ??? ???? ???.'); //??2: ?????? ?? ???? ??
$dbDir = $this->_dataDir.DIRECTORY_SEPARATOR.$dbName;
!is_dir($dbDir) && mkdir($dbDir)
//3??: ?? ??? ?? ???? ??????? ???? ??? ??? ?????
$this->_TableBak = new TableBak($this->_mysql_link_id,$dbDir)
if(is_null($tableName)){//backup all table in db
$this->_backupAllTable($dbName);
return
}
if(is_string($tableName)){
(strlen($tableName)==0) && die('....');
$this->_backupOneTable($dbName,$tableName)
return;
}
if (is_array($tableName)); ??>foreach ($tableName as $table){?
( (!is_string($table)) || strlen($table)==0) && die('....');?
}?
$this->_backupSomeTalbe($dbName,$tableName);?
return;?
}?
}
function RestoreDb($dbName,$tableName=null){
( (!is_string($dbName)) || strlen($dbName)==0 ) && die('$dbName? ??? ???? ???.' ); ?
//??1: ??????? ??? ???? ?????. ? ? ? ? ? ? ? ? ? ? ?>//??2: ?????? ?? ????? ??? ?????.
$dbDir = $this->_dataDir.DIRECTORY_SEPARATOR.$dbName; !is_dir($dbDir) && die("$dbDir? ???? ??");
//step3:?? ??
$this->_TableBak = new TableBak($this->_mysql_link_id,$dbDir);
if(is_null($tableName)){//db? ?? ??? ??
$this->_restoreAllTable($dbName)
return;
}
if(is_string( $tableName)){
(strlen($tableName)==0) && die('....')
$this->_restoreOneTable($dbName,$tableName)
return ;
}
if (is_array($tableName)){
foreach ($tableName? $table?){?
( (!is_string($table)) || strlen($table)== 0) && die('....');?
}?
$this->_restoreSomeTalbe($dbName,$tableName) ); >_mysql_link_id); ush( $tableList,mysql_tablename($result, $i));
}
mysql_free_result($result)
return $tableList; $dbName)
{
foreach ($this->_getTableList($dbName) as $tableName){
$this->_TableBak->backupTable($tableName); $tableName)?
{?
!in_array($tableName,$this->_getTableList($dbName)) && die("??? ??? ??$tableName ??????? ???? ????." );
$this->_TableBak->backupTable($tableName)
}
function _backupSomeTalbe($dbName,$TableNameList) ($TableNameList as $tableName){
!in_array( $tableName,$this->_getTableList($dbName)) && die("??? ??? ??$tableName? ??????? ???? ????.")
}
foreach( $TableNameList as $tableName){
$this->_TableBak->backupTable($tableName);
function _restoreAllTable($dbName)
{
//1??: ?? ??? ???? ?? ??? ?????, ?? ???? ??:
foreach ($this->_getTableList($dbName ) $tableName??){
$tableBakFile = $this->_dataDir.DIRECTORY_SEPARATOR
$dbName.DIRECTORY_SEPARATOR
$tableName.DIRECTORY_SEPARATOR??????????????????????????????????????????????????????????????is_writeable ($tableBakFile) && die("$tableBakFile? ???? ??? ? ? ??" ); {?
$tableBakFile?= $this->_dataDir.DIRECTORY_SEPARATOR?
???????????????????????????????????
$tableName.'.sql'; ;_TableBak->restoreTable($tableName,$ tableBakFile);?
}?
}?
function _restoreOneTable($dbName,$tableName)?
{?
//1??: ??? ???? ????? ??:?
!in_array($tableName, $this->_getTableList($dbName)) && die("??? ??? ??$tableName? ??????? ???? ????.");
//2??: ??? ??? ?? ?? ?? ??? ???? ?? ?? ??:
$tableBakFile = $this->_dataDir.DIRECTORY_SEPARATOR
. $dbName.DIRECTORY_SEPARATOR
.? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? ? ? ? ? ? ? ?$tableName.'.sql'
!is_writeable($tableBakFile ) && die("$tableBakFile? ??? ??? ? ??");
//3??:?? ??
$this->_TableBak-> ;restoreTable($tableName,$tableBakFile); ??????????????????????????????????????$tableName??){
!in_array($tableName,$this->_getTableList($dbName)) && die("??? ??? ??$tableName? ??????? ????.")
}
///2??: ??? ??? ?? ??? ???, ?? ???? ??:
foreach ($TableNameList as $tableName){
$tableBakFile = $this->_dataDir.DIRECTORY_SEPARATOR
. $dbName.DIRECTORY_SEPARATOR . $tableName.DIRECTORY_SEPARATOR . ??>!is_writeable ($tableBakFile) && die("$tableBakFile? ??? ? ? ??")????
//step3:?? ??:????
foreach?($TableNameList?as?$tableName){????
$tableBakFile?=?$this->_dataDir.DIRECTORY_SEPARATOR????
???????????????.?$dbName.DIRECTORY_SEPARATOR????
???????????????.?$tableName.DIRECTORY_SEPARATOR????
???????????????.?$?????.'.sql';????
$this->_TableBak->restoreTable($tableName,$tableBakFile);????
}????
}????
}????
?>?????
復(fù)代碼 代碼如下:
& lt;? PHP
// DBBAK? ? ???? ??? ? ????.
function TableBak($mysql_link_id,$dbDir)
{
$this->_mysql_link_id = $ mysql_link_id
$this->_dbDir = $dbDir;
}????
function backupTable($tableName)?
{?
//1??: ???? ?? ???? ??? ????.?
$tableDir = $this->_dbDir.DIRECTORY_SEPARATOR.$tableName;?
!is_dir($tableDir) && mkdir($tableDir);????????????????????????????????????????????????> @file($tableBakFile) ?? die("$tableBakFile ??? ? ? ??");?
$num = count($fileArray);?
mysql_unbuffered_query("DELETE FROM $tableName");?fileArray[0];?
for ($i=1;$i<$num-1;$i){??
mysql_unbuffered_query( $sql.$fileArray[$i]) ?? (die (mysql_error()) ); ??();
$sql="SELECT * FROM $tableName LIMIT 1";
$result = mysql_query($sql,$this->_mysql_link_id)
$num_field=mysql_num_fields($ ??) ;
$fieldInfo[$field_name] = $field_type;
mysql_free_result($result); fieldInfo,$row) {??
$row as $field_name=> $field_value){??
$field_value=strval($field_value);??
switch($fieldInfo[$field_name]){???
case "blob" :??????? $row[$field_name] = "'".mysql_escape_string( $field_value)."'";break;????????????????????????????????????????????????????????????????????????????????????????????????????????????????'";break;
case "date": $row[$field_name] = "'".mysql_escape_string($field_value)."'";break;
case "datetime": $row[$field_name] = "'".mysql_escape_string($field_value)."'";break;???
case "time":???$row[$field_name] = "'".mysql_escape_string($field_value )."'";break;???
case "unknown": $row[$field_name] = "'".mysql_escape_string($field_value)."'";break
case "int": $row[ $field_name] = intval($field_value);
case "real": $row[$field_name] = intval($field_value)
case "timestamp":$row[$field_name] = intval($field_value);
???: $row[$field_name] = intval($field_value)
}
}
return $row;
}
function _backupTable($tableName,$tableDir)
{
//???? ?? ?? ????:
$fieldInfo = $this-> ;_getFieldInfo ($tableName);
//step1: INSERT ?? ???? ???? ??? ???:
$fields = array_keys($fieldInfo)
$fields = implode(' ,',$fields);
$sqltext="INSERT INTO $tableName($fields)VALUES rn";
$datafile = $tableDir.DIRECTORY_SEPARATOR.$tableName.'.sql'; $handle = fopen($datafile ,'w')) && die("$datafile ??? ? ? ????.")
(!fwrite($handle, $sqltext)) && die ("$datafile ??? ???? ? ? ????.");?
fclose($handle);?
//2??: ???? ?? ??? ???:?
//Get ??? ???:?
set_time_limit (0);
$sql = "$tableName?? * ??";
$result = mysql_query($sql,$this->_mysql_link_id)//Open ??? ?? ??: $tableName.xml???????????????????????????????????????????????????????????????????????????$datafile");
/ /??? ???? ??? ???? ??? ???: ($fieldInfo,$row);?
$record= '(' . implode(',',$row) . ");rn";??
(!fwrite($handle, $record))?&& die ("$datafile< ??? ???? ? ? ????. ;/b>");
}
mysql_free_result($result);
//??? ????: ;??
return true; >require_once('DbBak.php');
require_once ('TableBak.php');
$connectid = mysql_connect('localhost','root','123456')
$backupDir = 'data'
$DbBak($connectid ,$backupDir);
$DbBak->backupDb('mybbs');
?? ??
??? ??? ????.
require_once('DbBak .php'); mysql_connect('localhost','123456');
???? postgresql ??????? ??? ???? mysql ?????? ?? ???? postgresql ?????? PHP ??? ?????. PHP ????? ??? ?? ????? ??? ??? ????.

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

PHP ?? ??? ?? ???? ?? ? ????? ??? ?????. 1. ?? ??? ??? ??? ??? ? ? ??? ??? ??? ?? ?? ??? ???? ???????. 2. ?? ??? ???? ???? ? ?? ????? ?? ?? ?? ??? ?????. 3. $ _get ? $ _post? ?? Hyperglobal ??? ?? ???? ?? ??? ? ??? ??? ??????? ???????. 4. ?? ?? ?? ???? ?? ?? ?? ??? ?????? ?? ??? ??? ?? ??? ???????. ??? ??? ????? ??? ??? ?? ???? ????? ? ??? ? ? ????.

PHP ?? ???? ???? ????? ?? ? ??? ???? ?? ?? ? ??? ???? ?? ??? ?????? ??? ??? ? ? ???????. 1. ??? ?? CSRF? ???? ?? ??? ??? ???? ?????? ??? ???? FINFO_FILE? ?? ?? MIME ??? ?????. 2. ??? ??? ??? ???? ??? ?? ??? ?? ? WEB ????? ??? ???? ??????. 3. PHP ?? ??? ?? ? ?? ???? NGINX/APACHE? ??? ????? ?? ???? ?????. 4. GD ?????? ??? ? ?? ???? ??? ?? ??? ?? ????.

PHP ?? ???? ? ?? ???? ??? ????. 1. // ?? #? ???? ? ?? ??? ???? // ???? ?? ????. 2. ?? /.../ ?? ?? ?? ??? ????? ?? ? ?? ??? ?? ? ? ????. 3. ?? ?? ?? / if () {} /? ?? ?? ??? ????? ??? ?? ?? ?? ??? ???? ????? ???? ??? ?? ???? ???? ??? ? ??? ??????.

Ageneratorinphpisamemory- ???? Way-Erate-Overgedatasetsetsbaluesoneatimeatimeatimeatimallatonce.1.generatorsuseTheyieldKeywordTocroadtOpvaluesondemand, RetingMemoryUsage.2

PHP ??? ???? ??? ??? ??? ????? ????. ??? ????? ?? ???? ??? "?? ? ?"??? "?"? ???????. 1. ??? ? ??? ??? DocBlock (/*/)? ?? ?? ??? ???? ??? ? ?? ???? ??????. 2. JS ??? ???? ?? ???? ??? ?? ??? ??? ?????. 3. ??? ?? ?? ?? ??? ???? ????? ????? ???? ?? ????? ???? ? ??????. 4. Todo ? Fixme? ????? ???? ? ? ??? ??? ???? ?? ?? ? ??? ???????. ??? ???? ?? ??? ??? ?? ?? ?? ???? ???? ? ????.

tolearnpheffectical, startBysetTupaloCalserErverEnmentUsingToolslikexamppandacodeeditor -likevscode.1) installxamppforapache, mysql, andphp.2) useacodeeditorforsyntaxsupport.3)) 3) testimplephpfile.next, withpluclucincludechlucincluclucludechluclucled

PHP??? ???? ??? ?? ?? ????? ???? ??? ?? ??? ??? ?? ? ??? ??? ???? ?????. ???? 0?? ???? ?? ??? ???? ? ?? ???? ?? ?? ? ? ????. MB_SUBSTR? ?? ??? ??? ???????. ? : $ str = "hello"; echo $ str [0]; ?? H; ??? MB_SUBSTR ($ str, 1,1)? ?? ??? ??? ??? ??????. ?? ???????? ???? ??? ???? ?? ???? ?? ?? ???? ?????? ??? ????? ?? ??? ?? ??? ???? ???? ?? ????.

toinstallphpquickly, usexampponwindowsorhomebrewonmacos.1. ??, downloadandinstallxAmpp, selectComponents, startApache ? placefilesinhtdocs.2
