Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Call A Stored Procedure From Php Rate Topic   - - - - -

 
  • technoob
  • Senior Member
  • Trial users
  • Join Date: 08-Jun 15
  • 309 posts

Posted 30 November 2017 - 01:20 PM #1

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 ??



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11115 posts

Posted 30 November 2017 - 08:54 PM #2

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.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • technoob
  • Senior Member
  • Trial users
  • Join Date: 08-Jun 15
  • 309 posts

Posted 01 December 2017 - 12:45 PM #3

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.



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11115 posts

Posted 01 December 2017 - 07:41 PM #4

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


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 

Posted 22 October 2018 - 05:15 AM #5

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?



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11115 posts

Posted 24 October 2018 - 07:39 PM #6

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.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.