Thursday, 2 July 2020
Wednesday, 1 July 2020
Sunday, 31 May 2020
Friday, 29 May 2020
Wednesday, 15 April 2020
Using PHP to Backup MySQL Databases
http://www.php-mysql-tutorial.com/wikis/mysql-tutorials/using-php-to-backup-mysql-databases.aspx
There are at least three ways to backup your MySQL Database :
To backup your MySQL database using phpMyAdmin click on the "export" link on phpMyAdmin main page. Choose the database you wish to backup, check the appropriate SQL options and enter the name for the backup file.
- Execute a database backup query from PHP file.
- Run mysqldump using system() function.
- Use phpMyAdmin to do the backup.
Execute a database backup query from PHP fileBelow is an example of using SELECT INTO OUTFILE query for creating table backup :
<?php
To restore the backup you just need to run LOAD DATA INFILE query like this
: include 'config.php'; include 'opendb.php'; $tableName = 'mypet'; $backupFile = 'backup/mypet.sql'; $query = "SELECT * INTO OUTFILE '$backupFile' FROM $tableName"; $result = mysql_query($query); include 'closedb.php'; ?>
<?php
It's a good idea to name the backup file as tablename.sql
so you'll know from which table the backup file isinclude 'config.php'; include 'opendb.php'; $tableName = 'mypet'; $backupFile = 'mypet.sql'; $query = "LOAD DATA INFILE 'backupFile' INTO TABLE $tableName"; $result = mysql_query($query); include 'closedb.php'; ?> |
Run mysqldump using system() functionThe system() function is used to execute an external program. Because MySQL already have built in tool for creating MySQL database backup (mysqldump) let's use it from our PHP script
<?php
include 'config.php'; include 'opendb.php'; $backupFile = $dbname . date("Y-m-d-H-i-s") . '.gz'; $command = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $dbname | gzip > $backupFile"; system($command); include 'closedb.php'; ?> |
Use phpMyAdmin to do the backup
This option as you may guessed doesn't involve any programming on your part. However I think i mention it anyway so you know more options to backup your database.To backup your MySQL database using phpMyAdmin click on the "export" link on phpMyAdmin main page. Choose the database you wish to backup, check the appropriate SQL options and enter the name for the backup file.
<style type="text/css">
.style1
{
width: 615px;
}
.style2
{
text-align: right;
width: 85px;
}
</style>
Monday, 6 April 2020
MySQL的JOIN用法
https://www.jianshu.com/p/600b99a8bc7f
下面一张图很好解释了笛卡尔积:
数据库中的JOIN称为连接,连接的主要作用是根据两个或多个表中的列之间的关系,获取存在于不同表中的数据。连接分为三类:内连接、外连接、全连接。另外还有
CROSS JOIN(笛卡尔积),个人认为如果要理解MySQL中JOIN的各种连接,只需要理解笛卡尔积就足够了。1 笛卡尔积
笛卡尔乘积是指在数学中,两个集合X和Y的笛卡尓积(Cartesian product),又称直积,表示为X × Y,第一个对象是X的成员而第二个对象是Y的所有可能有序对的其中一个成员。
下面一张图很好解释了笛卡尔积:
Sunday, 24 March 2019
Display a clock - Tryit Editor v3.6 (JavaScript)
<!DOCTYPE html>
<html>
<head>
<script>
function startTime() {
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
m = checkTime(m);
s = checkTime(s);
document.getElementById('txt').innerHTML =
h + ":" + m + ":" + s;
var t = setTimeout(startTime, 500);
}
function checkTime(i) {
if (i < 10) {i = "0" + i}; // add zero in front of numbers < 10
return i;
}
</script>
</head>
<body onload="startTime()">
<div id="txt"></div>
</body>
</html>
<html>
<head>
<script>
function startTime() {
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
m = checkTime(m);
s = checkTime(s);
document.getElementById('txt').innerHTML =
h + ":" + m + ":" + s;
var t = setTimeout(startTime, 500);
}
function checkTime(i) {
if (i < 10) {i = "0" + i}; // add zero in front of numbers < 10
return i;
}
</script>
</head>
<body onload="startTime()">
<div id="txt"></div>
</body>
</html>
Tuesday, 12 March 2019
JavaScript Array push() Method
Add a new item to an array:
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi");
https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_push
<!DOCTYPE html>
<html>
<body>
<p>Click the button to add a new element to the array.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
var fruits = ["Banana", "Orange", "Apple", "Mango"];
document.getElementById("demo").innerHTML = fruits;
function myFunction() {
fruits.push("Kiwi");
document.getElementById("demo").innerHTML = fruits;
}
</script>
</body>
</html>
Subscribe to:
Posts (Atom)
zomok E-commerce system plan. Choose your online ordering system. No-risk 30 day free trial. Then USD 9/month. No credit card required.
zomok E-commerce system plan. Choose your online ordering system. No-risk 30 day free trial. Then USD 9/month. No credit card required. h...
-
DePauhGarden BabaCuisineBatuKawan ShunkaBatuKawan YenBatuKawan PanPanBatuKawan CheongfatttzeCafeMangga Iramadining AkkasCurryHouse Restauran...
-
Complete TFTP Server example, using Indy components There are not many good TFTP server examples out there, so I wrote this example of...





