The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Stored Procedures / Routines + general US startup questions
#11
Thanks for looking at this Brandin.

The function I added to the DB class:
Code:
public function nextRowset(){
       if(!($this->_query->nextRowset())) return [];
       
       return $this->_query->fetchALL(PDO::FETCH_OBJ);
   }

is to allow access to  the second result set (and any further) returned from my stored procedure. As the $this->_query object/var is private to DB class I cannot call the pdo nextRowset() function on the $result variable in my code when using $result = $db->query(....etc.

The function I posted second was just my example of how I use the function added to the DB class. This is in one of my misc files somewhere:
Code:
private function my_fn($amount){

 $result = $db->query("CALL MY_PROC(?,?,?)",array($user->data()->id,$amount,NULL));

 $result_A = $result->results();
 $result_B = $result->nextRowset(); // <-- added to DB class

 var_dump($result_A, $result_B);
 exit();
}

For completeness, my stored proc essentially ends like this:
Code:
proc:BEGIN

-- GENERATE AND INSERT to TABLES

SELECT * from table_a WHERE ID = last_insert_id(); -- result set A

SELECT * from table_b WHERE guid LIKE concat(@guid_begin,'%'); -- result set B

END;

As i'm very rusty on my pdo (due to PEAR) I had to google to get the nextRowset() fn name, This is one of the SO pages I came across: 
SO multi query pdo

Like yourself, and mudmin, said - I think keeping track of the db.php file and re-adding my extra function if it changes is possibly the best solution for now, I've created a DB.mine file just in case.

On a separate note, I saw the vid on YT for version 4.4, looks great and looking forward to trying it out.

Thanks
  Reply
#12
Hi Developer_J,

Your solution seems proper after further explanation, and this information will even be useful for myself given the nature of my work, so thank you for this! We're happy to hear you enjoyed the 4.4 video, @mudmin did a fantastic job with it! Looking forward to hearing more from you if you require any support.

Brandin.
  Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)