This topic is locked
[SOLVED]

calling stored procedure with parameters

5/6/2021 5:57:51 PM
PHPRunner General questions
P
Phil78 author

In PhpRunner 10.5 they recommend to use DB::Query

I have a stored procedure with 2 parameters pID and a value (0 or 1).
I also have a global variable which store the ID ($_SESSION["user_id"])

for the moment I use CustomQuery and it works !
CustomQuery("CALL vidage(".$_SESSION['user_id'].",1)");

I would like to migrate to DB::
in the server event of my button I tried with
$proc = DB::PrepareSql("Call vidage ':1 :2'",':session.UserID',0);

$proc = DB::PrepareSql("Call vidage ':1 :2'",':$_SESSION["user_id"]',0);

$proc = DB::PrepareSql("Call vidage ':1' ':2'",':$_SESSION["user_id"]',0);

DB::Exec($proc);

but there is no execution ? I suppose the syntax of $proc is wrong ?

can you give me the good call, I tried with the support but their answer is not enough clear for me, i would have the good syntax ?

admin 5/8/2021

Troubleshooting issues like is easy. Instead of executing the query print it on the page, see what is wrong, run it manually against your database, change the code and repeat.

Simply trying different syntaxes is not enough, you need to understand what exactly is wrong,

P
Phil78 author 5/10/2021

You give me the same anwer than the support. When I run manually from my database it is ok. When I run from phpr with customquery it is ok.

My problem is only with DB::PrepareSql, so is anybody able to confirm me the good syntax to use with DB::PrepareSql ?

I made a new test this morning with phpr 10.5 buid 37031 and now it is OK, something has been fixed !

DB::PrepareSql("Call vidage ':1',':2'", $_SESSION['user_id'],'0');