X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   How call external stored procedure before page /?target=checkout loaded? (https://forum.x-cart.com/showthread.php?t=75372)

dagdag 05-23-2017 04:46 AM

How call external stored procedure before page /?target=checkout loaded?
 
Good day!

I really need to call my external stored procedure before the checkout page ( shop.com/?target=checkout as example) start loading.
Stored procedure located in x-cart database and does not use or return parameters.

How can this be realize most correctly? Thank you very much!

This is necessary to monitor the connection of the store with the external fiscal registrar.

qualiteam 05-29-2017 05:45 AM

Re: How call external stored procedure before page /?target=checkout loaded?
 
Do you mean stored procedures?

If so, working with them will be tricky a bit. X-Cart 5 works with the database via Doctrine that is an abstraction over different database types. But stored procedures are not consistent across different types of databases, so is not something that can be implemented as an abstract thing.

However, you can use "Native Queries" to run raw SQL queries against the database:
PHP Code:

\XLite\Core\Database::getEM()->getConnection()->executeQuery('YOUR RAW SQL QUERY GOES THERE'); 


Does this work?

---

I've been told by our support staff that using the same "database handle" for regular queries and stored procedures may result into "Commands out of sync" error. If this happens to you too, you may try to use the MySQL PDO or MySQLi directly (not via Doctrine).

dagdag 05-29-2017 08:19 PM

Re: How call external stored procedure before page /?target=checkout loaded?
 
Quote:

However, you can use "Native Queries" to run raw SQL queries against the database:

\XLite\Core\Database::getEM()->getConnection()->executeQuery('YOUR RAW SQL QUERY GOES THERE');

Does this work?

Yes! It works fine! MySQL store procedures (and functions too!) called from x-cart and run without errors.
You are my god! Thank!


All times are GMT -8. The time now is 05:20 PM.

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