akphidelt2007 Posted August 16, 2014 Share Posted August 16, 2014 Alright, I've been assigned a project at work. I did not develop the application and the individual who did used CodeIgnited framework and mysql as the db. Here's the problem, I'm not given much OT to do this and in our meeting the best way to proceed was to replicate the database for different parts of the organization. Basically we are a subsidiary and have been using an application that other groups within the organization want to use. Usually I would reconfigure the db schema and add org ids and in the user table add the appropriate organization to go to. However, they are not giving me enough time to do that. So what I'm thinking is to just create a copy of the database we use (just the structure) and create a new database. What I want to know is how to use mysql to check to see if a user exists in one database and if they don't then to go on to the next database. I understand this is a very sloppy way to do it, but it's the way we are moving forward. I found the code to connect to the db in CodeIgnitor... how can I connect to a database, check to see if the user exists, then close that db connection and try the next database? /** * Select the database * * @access private called by the base class * @return resource */ function db_select() { return @mysql_select_db($this->database, $this->conn_id); } Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/290486-selecting-different-database-based-on-usernamepassword-login/ Share on other sites More sharing options...
ginerjm Posted August 17, 2014 Share Posted August 17, 2014 I would put the users into a table in a separate db and search that db for the user in the table and use the db name stored in his entry. Search one db and then connect to the one specified 1 Quote Link to comment https://forums.phpfreaks.com/topic/290486-selecting-different-database-based-on-usernamepassword-login/#findComment-1487984 Share on other sites More sharing options...
akphidelt2007 Posted August 17, 2014 Author Share Posted August 17, 2014 I would put the users into a table in a separate db and search that db for the user in the table and use the db name stored in his entry. Search one db and then connect to the one specified That's an awesome idea. I will go this route. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/290486-selecting-different-database-based-on-usernamepassword-login/#findComment-1487993 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.