|
Posted by Jeff on 01/22/07 10:31
Hey
I've created a stored procedure in a MySql5 database, and now I want to call
this SP from my php (php version 5.2.0) code.
Basically I don't know how to call this SP so that my php code can retrieve
the id (see parameter list in my SP, this parameter is a INOUT parameter)
parameter, so I post here just in case some of you have some tips about
this.
I want to use the object-oriented approach of mysqli
CREATE PROCEDURE SaveProperty ( INOUT id int unsigned, field1 int, field2
int)
BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
END;
START TRANSACTION;
IF (id IS NULL) THEN
INSERT INTO Property (Field1, Field2) VALUES (field1, field2);
ELSE
UPDATE Property Set Field1 = field1, Field2 = field2 WHERE Id = id;
END IF;
COMMIT;
END;
Jeff
[Back to original message]
|