Search code examples
oraclepdoplaceholderauto-incrementnamed

PHP PDO Is there a way to disable named placeholders ( Oracle AUTOINCREMENT issue )


i am creating table in oracle ( odbc connection - has to be ). And i want to create auto increment column. That is not problem. The query i need to perform is following :

CREATE TRIGGER TBIUR_FOLDER_FOLDER_ID
BEFORE INSERT OR UPDATE
OF
FOLDER_ID
ON FOLDER
REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW
BEGIN 
IF :NEW."FOLDER_ID" IS NULL 
 THEN SELECT "SQ_FOLDER_FOLDER_ID".NEXTVAL INTO :NEW."FOLDER_ID" FROM dual;
END IF;
END;

The problem is in :NEW keyword , PDO takes it as named parameter so i am unable to create the trigger properly . When i check in the database the create query is :

IF :1."FOLDER_ID" IS NULL 

so :NEW is replaced by :1 :/ and i do not know what to do ...


Solution

  • Yes.
    You can disable prepared statements parsing at all.
    Just don't use them for this query, as it obviously don't need them. Just run it using query() or exec()