Welcome Guest, Not a member yet? Register   Sign In
oracle table primary key
#1

[eluser]junmin Liu[/eluser]
I know most of php frameworks are targeted at MySQL, particularly when comes to "insert" new row, it will assume the primary key will be "auto increment".

unfortunately i am using oracle. so how CI'S build-in database classes deal with creating oracle primary key? it will be nice it has some configuration to use oracle's sequence.

thanks
#2

[eluser]Frank Berger[/eluser]
From what you can see in the db-driver for oracle you're pretty much on your own here. I guess it wasn't implemented as you'd have to enforce a naming scheme for the sequence (table_seq for example) or you'd have to add a table-relevant configuration scheme in the db-config ('table'=>'sequence') or you'd have to rely that the db-admin sets up the tables with on-insert triggers (which would be from the framework point of view the most sensible and easiest to implement).

Counting in the problem that you'd like to have the last inserted id back with the insert_id method you will have to subscribe to one of those methods, which will imply that you either have to use transactions, or to fetch a new id before you're sure that the insert wont fail.

All of this would imply a certain way to structure your database, much more than that your id-field needs to be named 'id'.

But, if you'd subscribe to one of those methods, it would be trivial to adapt the oracle db-driver class as it is fairly simple.

Having that said, i don't see how most of the advanced db-ORM/functions/libraries will work without the auto_increment in the oracle driver, is anybody using CI and Oracle in a serious production environment?

Frank




Theme © iAndrew 2016 - Forum software by © MyBB