![]() |
Running Simple Selects on 3rd party table
Hello,
I would like to run some simple selects on a 3rd party table in my X-Cart 5.2 database. I tried to create an entity class and access it that way, but I noticed the X-Cart table prefix was added on so it just created a new table. Any sample code someone can share to point me in the right direction? Thanks! |
Re: Running Simple Selects on 3rd party table
Not sure if this is the best solution, but it works for MySQLi:
Code:
//Get the Connection info from X-Cart 5 Hope that helps! |
Re: Running Simple Selects on 3rd party table
I should also note you need to make sure to initialize X-Cart 5 by including top.inc.php if you're running this outside of the X-Carts's object model in your own PHP file:
Code:
//X-Cart initializtion |
Re: Running Simple Selects on 3rd party table
Thank You! It Works!
|
Re: Running Simple Selects on 3rd party table
You can execute raw MySQL queries like this:
Code:
$tablePrefix = \XLite::getInstance()->getOptions(array('database_details', 'table_prefix')); You should not use this for X-Cart 5 database tables (and use ORM instead), but it is OK to use this for non-X-Cart-5 tables in the same database. |
All times are GMT -8. The time now is 05:51 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.