1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

execute Stored Procedure with PHP Events list plugin

Discussion in 'Community' started by Nagtegaal, May 21, 2020.

  1. Nagtegaal

    Nagtegaal Member

    Level: Community

    I try to CALL a Stored Procedure from the mysql database using the PHP Events list plugin. On the onPreloadData part I entered this script (among others):

    try {
    $myDb = JFactory::getDbo();
    $sql = 'CALL sp_test()';
    $result = $myDb->prepare($sql);
    } catch (Exception $e) {

    But I get the error: Call to a member function execute() on null

    I can CALL the SP in mysql without error. In the wiki PHP common tasks I find examples about insert and update, but not calling a SP. I kept the Store Procedure as simple as possible, without any IN or OUT parameters.

    Any advice would be very welcome.
  2. Nagtegaal

    Nagtegaal Member

    Level: Community
    Well, at the end I got it to work, rebuilding the insert example.

    // Get a db connection.
    $myDb = JFactory::getDbo();

    // Create a new query object.
    $myQuery = $myDb->getQuery(true);


    // Reset the query using our newly populated query object.

    try {
    // Execute the query
    $result = $myDb->execute();
    catch (Exception $e) {
    // catch any database errors.
    die("Error occurred:" . $e->getMessage());
    dimoss likes this.

Share This Page