Is this possible?
Moderator: General Moderators
-
jclarkkent2003
- Forum Contributor
- Posts: 123
- Joined: Sat Dec 04, 2004 9:14 pm
Is this possible?
Is it possible to echo ALL the currentely set variables in a script? I'm trying to modifiy a wordpress 2.0 plugin for my own needs, but it's got issues.
It's supposed to recreate all the tables and insert data (for a multi blog setup) and it only sets up ONE "set" of all the tables each time, and then each additional time it loops, it doesn't create the tables. I need to know WHY as I can't figure it out.
I tried putting
ob_start()
ob_flush()
ob_end_clean();
INSIDE the for loop but BEFORE and AFTER the contents of that for loop, so I Was trying for it to do whatever it needed to do then do it again and again... but its' not working, so I need to know what varible is causing additional tables from being created......
Thanks.
It's supposed to recreate all the tables and insert data (for a multi blog setup) and it only sets up ONE "set" of all the tables each time, and then each additional time it loops, it doesn't create the tables. I need to know WHY as I can't figure it out.
I tried putting
ob_start()
ob_flush()
ob_end_clean();
INSIDE the for loop but BEFORE and AFTER the contents of that for loop, so I Was trying for it to do whatever it needed to do then do it again and again... but its' not working, so I need to know what varible is causing additional tables from being created......
Thanks.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
the globals superglobal array will have any variables defined in the global space.
get_defined_constants()
get_defined_functions()
get_declared_classes()
may also be of interest.
get_defined_constants()
get_defined_functions()
get_declared_classes()
may also be of interest.
-
jclarkkent2003
- Forum Contributor
- Posts: 123
- Joined: Sat Dec 04, 2004 9:14 pm
k yea I knew about that, but all the variables are not defined in the $GLOBALS array is the thing, there is no other way to display the entire set variables in a script?
Oh, something else SUPER important, Is it possible to COPY a mysql table inside a database ? I know about the RENAME database1 TO database2 but that gets rid of one, it just renames it. I need something to duplicate a entire TABLE inside one database from PHP code (not from root or shell access).
Is that possible, or is there part of a script somewhere here on this forum that can recuse the entire table, grab it's structure as well and create it again?
Thanks for the super fast response
Oh, something else SUPER important, Is it possible to COPY a mysql table inside a database ? I know about the RENAME database1 TO database2 but that gets rid of one, it just renames it. I need something to duplicate a entire TABLE inside one database from PHP code (not from root or shell access).
Is that possible, or is there part of a script somewhere here on this forum that can recuse the entire table, grab it's structure as well and create it again?
Thanks for the super fast response
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
If the variables aren't available in the global space, you'll have to figure out how to get to them, but it should be traversable through the global.
As for your secondary question: Look into the INSERT .. SELECT syntax
As for your secondary question: Look into the INSERT .. SELECT syntax
-
jclarkkent2003
- Forum Contributor
- Posts: 123
- Joined: Sat Dec 04, 2004 9:14 pm
ok great, that worked really well, but i'm wondering if it can be done a little more automatically....
Here is what worked:
and here is what DID NOT work but I'm wondering if it can be done like this, did I get syntax a little messed up?
The idea here is not having to list all the rows in the table, but instead copy each and every table ALL rows. Is there a way to insert ALL rows
....
Son of a gun, lol, figured it out while typing.....
Here is how to copy a ENTIRE table within a database for anyone who's looking:
I still have to find out how to get the database structure of oldtable and create newtable with the same database... Anyone know how to do that easily (basically how do I grab the structure of database1 so i can create database2 with same structure FROM PHP)? ( I don't want to waste time looking up that, right now, inside phpadmin I just went to export and exported the table, copied the structure and renamed, which will work ATM but isn't my final goal....
Here is what worked:
Code: Select all
INSERT `z_blog_wp_100_options` (option_id,blog_id,option_name,option_can_override,option_type,option_value,option_width,option_height,option_description,option_admin_level,autoload) SELECT * FROM `z_blog_wp_options`;Code: Select all
INSERT `z_blog_wp_100_options` * SELECT * FROM `z_blog_wp_options`;....
Son of a gun, lol, figured it out while typing.....
Here is how to copy a ENTIRE table within a database for anyone who's looking:
Code: Select all
INSERT `newtable` SELECT * FROM `oldtable`;- raghavan20
- DevNet Resident
- Posts: 1451
- Joined: Sat Jun 11, 2005 6:57 am
- Location: London, UK
- Contact:
This is the command to create a table like another existing table
I have not seen a command to create a database like another...but this is how you should usually duplicate a database;
Code: Select all
create table new_table like old_tableCode: Select all
use show databases;
and for every database returned use show tables;
and for every table returned, run show create table table_name-
jclarkkent2003
- Forum Contributor
- Posts: 123
- Joined: Sat Dec 04, 2004 9:14 pm
- raghavan20
- DevNet Resident
- Posts: 1451
- Joined: Sat Jun 11, 2005 6:57 am
- Location: London, UK
- Contact:
-
jclarkkent2003
- Forum Contributor
- Posts: 123
- Joined: Sat Dec 04, 2004 9:14 pm