X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   How to get data from other databases? (https://forum.x-cart.com/showthread.php?t=75569)

Eyeglasses Expert 08-02-2017 03:58 AM

How to get data from other databases?
 
I plan to install drupal, wordpress, and using different databases for www.buyeyeglasses.net. How to get data from drupal 8, and wordpress 4.8, pls?

tks

qualiteam 08-07-2017 07:47 AM

Re: How to get data from other databases?
 
X-Cart 5 uses Doctrine library to work with the database. Although it works with its own tables via the ORM part of the library, you still can execute raw SQL queries over database tables created by other applications - see the documentation on createNativeQuery() method there:
http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/native-sql.html

To get the entity manager that works with the XC5's database, do this:
PHP Code:

$entityManager = \XLite\Core\Database::getEM(); 


To work with other databases (created by other web applications) you can create custom "entity managers" - check how X-Cart 5 creates its own entity manager in \XLite\Core\Database::startEntityManager() method.

qualiteam 08-07-2017 07:55 AM

Re: How to get data from other databases?
 
Actually, there is an easier method if you don't need the ORM functions:
http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/index.html

Doctrine ORM works on top of Doctrine DBAL, so, in theory, you should be able to use it inside X-Cart 5 code too. However, I never tried this, and can't find examples in the source code of X-Cart 5.

Eyeglasses Expert 08-07-2017 01:15 PM

Re: How to get data from other databases?
 
www.buyeyeglasses.net is based on x-cart 4.7.8, not 5

qualiteam 08-15-2017 01:49 PM

Re: How to get data from other databases?
 
I don't understand the question then.
In X-Cart 4 there is no the abstract layer on top of MySQL - you work with "raw" SQL queries.
How would you access any MySQL database from a custom PHP script? PDO? Do the same inside X-Cart 4 scripts. Or do you face any specific problems with this method?


All times are GMT -8. The time now is 03:26 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.