zgkhoo Posted November 16, 2007 Share Posted November 16, 2007 how to create and store in multiple database? eg..when detect the user's input is male then store into a male's database while if female then store into a female's database how to write a control of store different type of group into different db? thanks.. Link to comment https://forums.phpfreaks.com/topic/77624-how-to-create-and-store-in-multiple-database/ Share on other sites More sharing options...
~n[EO]n~ Posted November 16, 2007 Share Posted November 16, 2007 Create a variable for a database and check it in if..else condition if ($male) { $sLocalDatabaseName = "male_db"; } else { $sLocalDatabaseName = "female_db"; } and after that you need to define your connection $conn = mysql_connect($sLocalHost,$sLocalUser,$sLocalPassword); $db=mysql_select_db($sLocalDatabaseName); By the way, you can do this using 2 tables. No need of multiple DB. Link to comment https://forums.phpfreaks.com/topic/77624-how-to-create-and-store-in-multiple-database/#findComment-392934 Share on other sites More sharing options...
thryb Posted November 16, 2007 Share Posted November 16, 2007 You dont really want to use multiple DB for that, juste use 2 different Table Tbl_Male Tbl_Female store in there. Link to comment https://forums.phpfreaks.com/topic/77624-how-to-create-and-store-in-multiple-database/#findComment-392935 Share on other sites More sharing options...
thryb Posted November 16, 2007 Share Posted November 16, 2007 Or that but why would you want to use 2 DB ? Link to comment https://forums.phpfreaks.com/topic/77624-how-to-create-and-store-in-multiple-database/#findComment-392936 Share on other sites More sharing options...
zgkhoo Posted November 16, 2007 Author Share Posted November 16, 2007 cos the data that input will be huge..for this two group. i afraid one db with two huge table will over the total limit so i decided two or more db for different group ... am i rite? thanks.. Link to comment https://forums.phpfreaks.com/topic/77624-how-to-create-and-store-in-multiple-database/#findComment-393225 Share on other sites More sharing options...
teng84 Posted November 17, 2007 Share Posted November 17, 2007 its all about normalization again..... if you dont know how to normalize then you need more than 2 DB joke! Link to comment https://forums.phpfreaks.com/topic/77624-how-to-create-and-store-in-multiple-database/#findComment-393244 Share on other sites More sharing options...
zgkhoo Posted November 18, 2007 Author Share Posted November 18, 2007 n~ link=topic=167981.msg740495#msg740495 date=1195227370] Create a variable for a database and check it in if..else condition if ($male) { $sLocalDatabaseName = "male_db"; } else { $sLocalDatabaseName = "female_db"; } and after that you need to define your connection $conn = mysql_connect($sLocalHost,$sLocalUser,$sLocalPassword); $db=mysql_select_db($sLocalDatabaseName); By the way, you can do this using 2 tables. No need of multiple DB. then how to switch between two or more tables? Link to comment https://forums.phpfreaks.com/topic/77624-how-to-create-and-store-in-multiple-database/#findComment-393789 Share on other sites More sharing options...
~n[EO]n~ Posted November 18, 2007 Share Posted November 18, 2007 Are you really using more that 1 database. It will be a headache later... Same thing can be achieved through 1 database with two tables for male and female. Link to comment https://forums.phpfreaks.com/topic/77624-how-to-create-and-store-in-multiple-database/#findComment-393792 Share on other sites More sharing options...
fenway Posted November 19, 2007 Share Posted November 19, 2007 n~ link=topic=167981.msg741358#msg741358 date=1195376146] Are you really using more that 1 database. It will be a headache later... Same thing can be achieved through 1 database with two tables for male and female. You're talking about vertical partitioning... that's an advanced technique. Link to comment https://forums.phpfreaks.com/topic/77624-how-to-create-and-store-in-multiple-database/#findComment-394457 Share on other sites More sharing options...
zgkhoo Posted November 19, 2007 Author Share Posted November 19, 2007 nope....changed to multiple table instead of multiple db. already... how to list out all table name in my db? i need compare with my record...if $gender==$tablename then...store....into $tablename how? thanks in advance Link to comment https://forums.phpfreaks.com/topic/77624-how-to-create-and-store-in-multiple-database/#findComment-394470 Share on other sites More sharing options...
fenway Posted November 19, 2007 Share Posted November 19, 2007 SHOW TABLES will get you the listing... the other question you have is a php issue. Link to comment https://forums.phpfreaks.com/topic/77624-how-to-create-and-store-in-multiple-database/#findComment-394471 Share on other sites More sharing options...
zgkhoo Posted November 19, 2007 Author Share Posted November 19, 2007 SHOW TABLE sample code pls.. thanks.. Link to comment https://forums.phpfreaks.com/topic/77624-how-to-create-and-store-in-multiple-database/#findComment-394475 Share on other sites More sharing options...
fenway Posted November 19, 2007 Share Posted November 19, 2007 SHOW TABLE sample code pls.. thanks.. That is the sample code... and it's TABLES. I suggest you take a closer look at the refmac. Link to comment https://forums.phpfreaks.com/topic/77624-how-to-create-and-store-in-multiple-database/#findComment-394511 Share on other sites More sharing options...
Hooker Posted November 19, 2007 Share Posted November 19, 2007 Can i ask one thing, how different are the structures for the "Male" and "Female" tables. Link to comment https://forums.phpfreaks.com/topic/77624-how-to-create-and-store-in-multiple-database/#findComment-394581 Share on other sites More sharing options...
zgkhoo Posted November 22, 2007 Author Share Posted November 22, 2007 no different..cos i wanna backup each male/female in different db/table Link to comment https://forums.phpfreaks.com/topic/77624-how-to-create-and-store-in-multiple-database/#findComment-396487 Share on other sites More sharing options...
fenway Posted November 22, 2007 Share Posted November 22, 2007 no different..cos i wanna backup each male/female in different db/table I don't think you do. Link to comment https://forums.phpfreaks.com/topic/77624-how-to-create-and-store-in-multiple-database/#findComment-396695 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.