onlyican Posted November 25, 2006 Share Posted November 25, 2006 Hey guysI am looking at creating an option to back up the databases, creating a wicked .sql fileCurrently I would back up using Mysql-frontWhich will give me a result such asCREATE TABLE IF NOT EXISTS mytable (id_num INT(12) auto_increment,name VARCHAR(150) DEFAULT NULL,PRIMARY KEY (id_num),) ENGINE=MyISAM AUTO_INCREMENT=25 DEFAULT CHARSET=latin1Which I can do using the Mysql Function SHOW CREATE TABLE mytableBUTHow would I get the dataWould I do something like[code]<?php$query = "SELECT * FROM mytable";$result = mysql_query($query);while($row = mysql_fetch_assoc($result)){$update[] = "INSERT INTO mytable (id_num, myname) VALUES ('".$row["id_num"]."', '".$row["myname"]."')";}?>[/code]Yes I know it will need a little bit more coding than that, but the principle is thereOr is there another wicked function in mysql which will show the results like I want Link to comment https://forums.phpfreaks.com/topic/28430-mysql-backup/ Share on other sites More sharing options...
ataria Posted November 25, 2006 Share Posted November 25, 2006 <?php$result = mysql_query("SELECT * FROM `mytable`");while($row = mysql_fetch_assoc($result)){$update = "INSERT INTO `mytable` (`id_num`, `myname`) VALUES ('{$row["id_num"]}', '{$row["myname"]}')";}?> Link to comment https://forums.phpfreaks.com/topic/28430-mysql-backup/#findComment-130088 Share on other sites More sharing options...
onlyican Posted November 25, 2006 Author Share Posted November 25, 2006 Pretty much what i said, but I want to know is there a function which will auto create them like SHOW CREATE TABLE tbl_name for creating the tablesI could do SHOW FIELDS but that builds it for me Link to comment https://forums.phpfreaks.com/topic/28430-mysql-backup/#findComment-130092 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.