Reputation: 95
I'm getting crazy trying to call, inside PHP code, a function that returns void, with pg_prepare/pg__execute...
$result = pg_prepare($dbconn, "",'SELECT * FROM dungeonasdb.crea_personaggio( "$nome", "$descrizione", "$email", "$password")');
$result = pg_execute($dbconn, "", NULL ) or die('Query creazione fallita');
Is there any settings of pg_prepare/pg_execute that I do wrong? Thanks
Upvotes: 1
Views: 212
Reputation: 6328
You probably want to do something different:
pg_prepare
: don't put specific values, but placeholders. You will bind them to values later on. I prefer to always give statements a name.
If dungeonasdb.crea_personaggio
is the function that returns void
, you can call it by means of:
SELECT dungeonasdb.crea_personaggio(...)
You cannot call your function by means of SELECT * FROM dungeonasdb.crea_personaggio(...)
because this would imply that dungeonasdb.crea_personaggio
is a set returning function, which is not.
So you probably want your statements to be:
$result = pg_prepare($dbconn, "crea_personnagio",
'SELECT dungeonasdb.crea_personaggio($1, $2, $3, $4)');
$result = pg_execute($dbconn, "crea_personnagio",
ARRAY($nome, $descrizione, $email, $password))
or die('Query execuzione fallita');
Your second statment is a pg_execute
statement that binds parameters to the placedholders ($1
, ...), and executes.
Upvotes: 1