Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

How to get data from other databases?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 08-02-2017, 03:58 AM
 
Eyeglasses Expert Eyeglasses Expert is offline
 

eXpert
  
Join Date: May 2010
Posts: 306
 

Default 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
Reply With Quote
  #2  
Old 08-07-2017, 07:47 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default 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.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
  #3  
Old 08-07-2017, 07:55 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default 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.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
  #4  
Old 08-07-2017, 01:15 PM
 
Eyeglasses Expert Eyeglasses Expert is offline
 

eXpert
  
Join Date: May 2010
Posts: 306
 

Default Re: How to get data from other databases?

www.buyeyeglasses.net is based on x-cart 4.7.8, not 5
Reply With Quote
  #5  
Old 08-15-2017, 01:49 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default 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?
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 03:41 AM.

   

 
X-Cart forums © 2001-2020