Call A Stored Procedure From Php

Do we have some existing code in main database libraries which can help in calling a stored procedure from php code, like db_query function ??

Your question is not clear.

You can create stored procedures using db_query() and then reference them in other queries.

However, given that cs-cart fudges the company_id's for single-store installs, you probably won't be able to use store_procedures for standard queries in cs-cart. They have a hook that looks for SELECT, DELETE, INSERT, REPLACE, etc. and then alter the queries by adding a company_id parameter and/or searching of the ult_* tables.

If you are doing this within your own addon and you are not referencing standard tables like 'products' and it's counterparts, then you can probably use stored procedures just fine.

i have created a stored procedure which i want to run from the backend / admin panel when i want so i need to create a controller which when accessed using a link on admin panel will run that stored procedure in mysql.

e.g. The Stored procedure i created is : update_products

now how do i call this sp from php.

db_query("whatever sql you want to execute");

When I execute stored procedure like

db_query("CALL stored_procecure_name");

its loading for longtime and not returning maximum execution time error. After increasing

execution time. Its not returning any result. Its loading for longtime without returning any result. Can you please advice me on this?

You would have to investigate in the mySQL logs on your server to see what is happening.

Have you verified your stored procedure in phpMyAdmin to ensure it doesn't have an infinate loop?

Note that php timeouts are based on CPU execution time of the PHP process. Since this has been passed off to mysqld, the PHP process is simply waiting for a response. Hence, it's not accumulating any time.