ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

How To Set Default Schema On DB2 Using PDO

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How To Set Default Schema On DB2 Using PDO

    We are creating a new system written in PHP on our iSeries linked to the DB2 database, based on one of our websites that was written for a MySQL database where the SQL access was all done using PDO.
    Since we have a database object and all the required methods already existing, it seems logical (to us) that we should retain PDO for this new system.

    However, even though we have been able to access DB2 files using PDO, we haven't found a way to set the default schema, which is very frustrating.
    Most of our files are in one schema, which will change between live and test databases. Currently the only way we can access data is to add the schema to all SQL statements, which is very frustrating.
    Is there a way to define a default schema at connection time like there is using DB2_connect?
    Poddys Rambles On

  • #2
    I take it you tried 'SET CURRENT SCHEMA = schama name'

    Comment


    • #3
      Ah yes, that works perfectly, thanks Rocky.

      If we were using MySQL there is a wealth of information, but IBM/DB2 SQL still suffers, especially where PDO is concerned.
      We were able to port a database object across from another of our websites to the iSeries and to change it to access Db2 with minimum changes, which is really good.
      Otherwise, without using PDO the way MySQL and DB2 SQL are coded in PHP is very different.
      Poddys Rambles On

      Comment


      • #4
        Probably too late to be useful to you but ... You could have continued to use MySQL and simply specified the DB2 storage engine. That would have allowed you to keep the PHP as-is and still be able to access the tables with RPG or whatever.

        Comment

        Working...
        X