Welcome Guest, Not a member yet? Register   Sign In
How to get database schema.
#1

[eluser]vikas khairnar[/eluser]
Hello,


I want to take database schema,how it is possible using CI class.
#2

[eluser]umefarooq[/eluser]
you want to display schema or want to backup of your database, please make it clear.
#3

[eluser]vikas khairnar[/eluser]
I want to Backup Database Schema.

I have 4 options in my form that is

1)Backup Database Schema
2)Backup Database Data
3)Compress Database
4)Download Database


I have implemented all 3 (2,3,4) but for option number 1 what to do?
#4

[eluser]umefarooq[/eluser]
here is the solution for you

http://ellislab.com/codeigniter/user-gui...tml#backup
#5

[eluser]vikas khairnar[/eluser]
Yes I have used same but how can I take backup of only data and only structure of tables separately.
#6

[eluser]rogierb[/eluser]
This you have to do yourself, there is no CI function to my knowledge


You can use:
SHOW TABLES
and
SHOW CREATE TABLE "tablename"

As for only the data, take a look at the mysql_utility.php file (_backup method)
#7

[eluser]bigtony[/eluser]
[quote author="vikas khairnar" date="1258486015"]Yes I have used same but how can I take backup of only data and only structure of tables separately.[/quote]
For database backup use:
Code:
$this->dbutil->backup();
For schema use:
Code:
$this->db->list_tables();
// and
$this->db->field_data('table_name');
#8

[eluser]vikas khairnar[/eluser]
But I want create and drop table structure for all of my database.
#9

[eluser]jedd[/eluser]
[quote author="vikas khairnar" date="1258541908"]
But I want create and drop table structure for all of my database.
[/quote]

What I do is have two sets of scripts - a CREATE_ set and an INSERT_ set. There's one of each type for every table in my database. I have a CREATE.mysql that simply source's the full set of CREATE_xyz.mysql files, with a first line that drops the database. The INSERT.mysql works similarly, of course.

This means I can recover my DB with test data with two commands (source CREATE.mysql , source INSERT.mysql).

I did this from the outset. If you want to get there from where you are now, you're going to have to do some dumps and tidies.

But it's not really a CI problem, is it?
#10

[eluser]vikas khairnar[/eluser]
Can you please tell me how you are create that both create.mysql and insert.mysql from code.




Theme © iAndrew 2016 - Forum software by © MyBB