سؤال

I have a site with a vanilla forum and an OpenCart store. I would like the users to be able to log in to both databases using one login from either the forum or the cart. For example, if they log in to the forum then navigate to the cart, they would already be logged in

هل كانت مفيدة؟

المحلول

See: http://dev.mysql.com/doc/refman/5.1/en/select.html

You can have your user table hosted in one database, and your shop hosted in another. As long as your connected mysql user has read and/or write access to all databases named in the query, there is no issue. It doesn't matter which database you initial connect to as that only sets the current relative database you're working with. You can reference tables across any number of databases accessible by the connection and user.

In your sql statements, to reach across tables located in other databases on the same server, use the syntax database_name.table_name, and database_name.table_name.column_name to reference a column in a table in another database on that server.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top