Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9299028

Browse files
committed
v1.1.4
1 parent 9b24744 commit 9299028

File tree

10 files changed

+1821
-1821
lines changed

10 files changed

+1821
-1821
lines changed

‎README.md‎

Lines changed: 99 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,58 @@
1-
# **Backup-SQL-By-Chak10** (V 1.0.7)
1+
# **Backup-SQL-By-Chak10** (BETA V1.1.4)
22

3-
BACKUP TABLE OR DATABASE MySQL with PHP.
3+
**New**BACKUP TABLE OR DATABASE MySQL with PHP.
44

55
``` php
6-
$backup = new SQL_Backup();
7-
```
6+
function __construct($con = null, $table_name = null, $ext = null, $fname = null, $folder = null, $query_limit = null, $archive = null, $phpmyadmin = null, $save = null, $sql_unique = null, $down = null, $header_name = null, $del_csv = null, $enc_csv = null, $json_options = null) {}
7+
```
8+
var _**con**_ (Object) => MySQLi or PDO connection already opened. (N.B. It is recommended that you use the connection to the database inside the class) [READ CON SECTION](#con)
89

9-
___**construct**_(_$con, $tablename, $folder, $querylimit, $compress, $ext, $alltableinfile, $save, $sqlunique_)
10+
var _**table_name**_ (String or Array) => The tables that you want to backup. [READ TABLE SECTION](#-table_name)
1011

11-
var _**con**_ (Object) => MySQLi connection already opened.
12+
var _**ext**_ (_String or Array_) => The extension of the destination file. [READ EXT SECTION](#execute)
1213

13-
var _**table_name**_ (String or Array) => The tables that you want to backup. [READ TABLE SECTION](https://github.com/Chak10/Backup-SQL-By-Chak10/blob/master/README.md#-table_name-string-or-array)
14+
var _**fname**_ (String) => The name of the output file/directory secondary
1415

1516
var _**folder**_ (String) => The folder where the files will be saved
1617

17-
var _**query_limit**_ (Int) => Number of queries at a time to execute in SQL [READ QUERY LIMIT SECTION](https://github.com/Chak10/Backup-SQL-By-Chak10/blob/master/README.md#query_limit-int)
18+
var _**query_limit**_ (Int) => Number of queries at a time to execute in SQL [READ QUERY LIMIT SECTION](#query_limit)
1819

19-
var _**compress**_ (Bool) => If set to true the result is compressed. (.zip)
20+
var _**archive**_ (Bool) => It results as an archive. (.zip|.tar)
2021

21-
var _**ext**_ (_String or Array_) [NEW VERSION >= V1.0.7] => The extension of the destination file. [READ EXT SECTION](https://github.com/Chak10/Backup_SQL-PHP-ByChak10/blob/master/README.md#ext-string-or-array)
22+
var _**phpadmin**_ (Bool) => If set to true, it creates files that can be imported directly with phpmyadmin. (sql|csv)
2223

23-
var _**ext**_ (Int) [OLD VERSION < V1.0.7] => The extension of the destination file. [READ EXT SECTION](https://github.com/Chak10/Backup-SQL-By-Chak10/blob/master/README.md#ext-int)
24+
var _**save**_ (Bool) => If set to false, the result will not be saved but will be loaded on the variable of class sql, csv, json (Based on request) [READ SAVE SECTION](#save)
2425

25-
var _**alltable_in_file**_ (Bool) => If set to true:
26-
- If the 'compress' variable is true all the files will be saved in a single zip file otherwise all will be saved individually
27-
- If the 'compress' variable is false all the files will be saved into a single folder (Depending on the extension) or else each file will be saved individually
26+
var _**sql_unique**_ (Bool) => If set to true the SQL dump is a single file with all the tables. (Valid only for the SQL format)
2827

29-
var _**save**_ (Bool) => If set to false, the result will not be saved but will be loaded on the variable of class sql, csv, json (Based on request) [READ SAVE SECTION](https://github.com/Chak10/Backup-SQL-By-Chak10/blob/master/README.md#save-bool)
28+
var _**down**_ (Bool) => If set to true, the output is automatic downloaded. (zip)
3029

31-
var _**sql_unique**_ (Bool) => If set to true the SQL dump is a single file with all the tables. (Valid only for the SQL format)
30+
[**Execution Times**](https://github.com/Chak10/Backup_SQL-PHP-ByChak10/blob/master/beta/bench.md)
31+
32+
## USE
33+
34+
``` php
35+
$backup = new SQL_Backup();
36+
```
3237

33-
[**Execution Times**](https://github.com/Chak10/Backup_SQL-PHP-ByChak10/blob/master/benchmark/bench_time_exec.md)
38+
### _con()_
3439

35-
### _con($HOST,$USER,$PASSWD,$NAME,$PORT=null,$SOCK=null)_
40+
```php
3641

37-
This Function is an simple MySQL connection (new mysqli())
42+
/**
43+
* @var $HOST string The MySQL host name.
44+
* @var $USER string The MySQL user name.
45+
* @var $PASSWD string The MySQL password.
46+
* @var $NAME string The MySQL database name.
47+
* @var $PORT int The port number to use when connecting to the database server otherwise it uses the default port
48+
* @var $SOCK string The socket name to use when connecting to a local database server otherwise it uses the default socket.
49+
* @return Bool | object
50+
**/
51+
52+
public function con($HOST, $USER, $PASSWD, $NAME, $PORT = null, $SOCK = null) {}
53+
```
54+
55+
This feature based on the extensions present uses the most appropriate connection (MYSQLi|PDO)
3856

3957
EXAMPLE:
4058

@@ -48,8 +66,8 @@ $NAME = 'francesco';
4866
Case : Connection already open...
4967

5068
``` php
51-
$con = new mysqli($HOST,$USER,$PASSWD,$NAME);
52-
$backup = new SQL_Backup($con);
69+
$con = new mysqli($HOST,$USER,$PASSWD,$NAME); // or PDO
70+
$backup = new SQL_Backup($con);
5371
```
5472

5573
Case : Connection closed....
@@ -59,15 +77,36 @@ $backup = new SQL_Backup();
5977
$backup->con($HOST,$USER,$PASSWD,$NAME);
6078
```
6179

62-
### _execute(void)_
80+
### _execute()_
81+
82+
``` php
83+
/**
84+
* @var $debug Bool (True|False)
85+
* @return Bool | Array
86+
**/
87+
public function execute($debug = false) {}
88+
```
6389

6490
Run Command
6591

66-
**Is critical . To run every time at the end!**
92+
If $debug **does not coincide** __(===)__ with true the result will be:
93+
94+
- If $save is true and there are no errors return true otherwise return false
95+
- If $save is false and there are no errors return array with tables [READ SAVE SECTION](#save) otherwise return false
96+
97+
If $debug **coincides** __(===)__ with true the result will be an array with all the class variables.
98+
99+
EXAMPLE:
67100

101+
``` php
102+
$backup = new SQL_Backup(...);
103+
$res = $backup->execute();
104+
var_dump($res);
105+
```
68106

69-
### $ _table_name_ (_String or Array_)
107+
**Is critical . To run every time at the end!**
70108

109+
### $ _table_name_
71110
The tables that you want to backup.
72111

73112
EXAMPLE:
@@ -85,14 +124,14 @@ $backup->table_name = array('users','alldata');
85124
```
86125
**If not set, it will backup all the database**
87126

88-
### $_folder_ (_String_)
127+
### $_folder_
89128

90129
``` php
91130
$backup->folder = "backup/database"; /* ONLY DIR */
92131
```
93132

94133

95-
### $_query_limit_ (_Int_)
134+
### $_query_limit_
96135

97136
Number of queries at a time to execute in SQL.
98137

@@ -107,19 +146,24 @@ Exemple q_limit = 400
107146
$backup->qlimit=400;
108147
```
109148

110-
### $_compress_ (_Bool_)
149+
### $_archive_
150+
151+
If set to true the result is an archive. (.zip|.tar)
152+
153+
N.B. Zip is compressed - Tar is not compressed.
111154

112-
If set to true the result is compressed. (.zip)
113155

114156
``` php
115-
$backup->compress = true;
157+
$backup->archive = false;
158+
// or
159+
$backup->archive = 'tar';
160+
// or
161+
$backup->archive = 'zip';
116162
```
117163

118164
[More info](https://github.com/Chak10/Backup_SQL-PHP-ByChak10/blob/master/benchmark/bench_size_exec.md)
119165

120-
### $_ext_ (_String or Array_)
121-
122-
**NEW VERSION >= V1.0.7**
166+
### $_ext_
123167

124168
The extension of the destination file.
125169

@@ -199,133 +243,48 @@ SETTING
199243
$backup->del_csv=";";
200244
$backup->enc_csv="'";
201245
```
202-
### $_ext_ (_Int_)
203-
204-
**OLD VERSION < V1.0.7**
205-
206-
The extension of the destination file.
207246

208-
``` php
209-
const SQL = 13;
210-
const CSV = 26;
211-
const JSON = 49;
212-
```
213-
- SQL extension
247+
### $_phpmyadmin_
214248

249+
If set to true it gives a result that can be imported directly with phpmyadmin (sql|csv)
215250

216251
``` php
217-
$backup->ext = $backup::SQL;
252+
$backup->phpmyadmin = true;
218253
```
219254

220-
``` php
221-
$backup->ext = 13;
222-
```
223-
- CSV extension
224255

225-
``` php
226-
$backup->ext = $backup::CSV;
227-
```
228-
229-
``` php
230-
$backup->ext = 26;
231-
```
232-
- JSON extension
233-
234-
``` php
235-
$backup->ext = $backup::JSON;
236-
```
237-
238-
``` php
239-
$backup->ext = 49;
240-
```
241-
242-
#### Combinations
243-
244-
SQL + CSV
245-
246-
``` php
247-
$backup->ext = $backup::SQL + $backup::CSV;
248-
```
249-
250-
``` php
251-
$backup->ext = 13 + 26; // 39
252-
```
253-
254-
``` php
255-
$backup->ext = array($backup::SQL, $backup::CSV);
256-
```
257-
258-
``` php
259-
$backup->ext = array(13,26);
260-
```
261-
262-
``` php
263-
$backup->ext = "39";
264-
```
265-
266-
**Same for JSON and CSV or JSON and SQL**
267-
268-
**_For all three formats use ($n > 100)_**
269-
270-
> NOTE: If you use the CSV extension, if you want you can add the field delimiter and the enclosure of the camps.
271-
By default they are:
272-
- Delimiter => ,
273-
- Enclosure =>
274-
275-
>Example: Data,DATA2,datA3
276-
277-
SETTING
278-
``` php
279-
$backup->del_csv=";";
280-
$backup->enc_csv="'";
281-
```
282-
283-
### $_alltable_in_file_ (_Bool_)
284-
285-
If set to TRUE:
286-
287-
- If the 'compress' variable is true all the files will be saved in a single zip file otherwise all will be saved individually.
288-
289-
- If the 'compress' variable is false all the files will be saved into a single folder (Depending on the extension. Example Choose SQL extension dir/sql/name_file) or else each file will be saved individually.
290-
291-
``` php
292-
$backup->alltable_in_file = true;
293-
```
294-
295-
296-
### $_save_ (_Bool_)
256+
### $_save_
297257

298258
If set to FALSE, the result will not be saved but will be loaded on the variable of Class sql, csv, json (**ARRAY**)
299259

300260
EXAMPLE
301261

302-
SQL:
303-
304-
object(SQL_Backup)[1]
262+
JSON:
305263

306-
...
307-
public 'sql' =>
308-
array (size=1)
309-
'name_table' => string '...'
310-
264+
```txt
265+
array (size=1)
266+
'json' =>
267+
array (size=1)
268+
'airports' => string '[{"id":"6523","ident":"00A","type":"heliport","name":"Total Rf Heliport","latitude_deg":"40.07080078125","longitude_deg":"-74.93360137939453","elevation_ft":"11","continent":"NA","iso_country":"US","iso_region":"US-PA","municipality":"Bensalem","scheduled_service":"no","gps_code":"00A","iata_code":"","local_code":"00A","home_link":"","wikipedia_link":"","keywords":""},{"id":"323361","ident":"00AA","type":"small_airport","name":"Aero B Ranch Airport","latitude_deg":"38.704022","longitude_deg":"-101.473911","'... (length=20358868)
269+
```
311270

312-
### $_sql_unique_ (_Bool_)
271+
### $_sql_unique_
313272

314273
If set to true the SQL dump is a single file with all the tables. (Valid only for the SQL format)
315274

316275
> Table 1 SQL + Table 2 SQL + ETC.
317276
318-
## In V 1.0.5
319-
320-
Added:
277+
### $_json_option_
321278

322-
### $_close_ (_Bool_)
279+
The classic options that can be used with json_encode.
323280

324-
If set to true, at the end of operations the MySQL connection is closed otherwise the connection will be allowed in the class.
281+
[README](http://php.net/manual/en/function.json-encode.php)
325282

326-
### $_json_pretty_ (_Bool_)
283+
EXAMPLE
327284

328-
If set to true, the output of the json will be like this:
285+
``` php
286+
$backup->json_option = JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES;
287+
```
329288

330289
``` json
331290
{
@@ -338,42 +297,21 @@ If set to true, the output of the json will be like this:
338297
"Avg": 0.5024807643890381
339298
}
340299
```
341-
Otherwise:
342-
343-
``` json
344-
{"Info":{"alldata":{"R":35954,"C":14}},"Avg":0.5024807643890381}
345-
```
346-
347-
### $_info_t_ (_Bool_)
348-
349-
If set to true, some information will be returned in the info array. (Look under)
350300

351-
### $_info_ (_Array_)
352-
353-
Here it will be returned any errors or information.
354-
355-
MySQL Error, table columns and rows, etc.
356-
357-
Example:
358-
359-
``` json
360-
{"alldata":{"R":35954,"C":14}
361-
```
362301

363302
## DEFAULT SETTING
364303

365304
- Folder = "backup/database";
366305
- Query Limit = 400
367-
- Compress = true
306+
- Archive = zip
368307
- Extension = SQL
369-
- Alltable_in_file = false
308+
- Phpmyadmin = false
370309
- Save = true
371310
- Sql_unique = false
372311
- Del= [,]
373312
- Enc= []
374-
- Close = null
375-
- Info_t = null
376-
- Json_pretty = null
313+
- Json_option = null
314+
- Down = null
377315

378316
> **Note: Attention this class has not been tested in all possible situations. So if you have problems you disclose them to me.**.
379317
File renamed without changes.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /