Foreign key support is missing

Issue #81 resolved
Former user created an issue

Originally reported on Google Code with ID 81

According to the MissingFeatures list, foreign keys should be implemented.
One of the comments suggested that foreign keys are supported because triggers are
However, SQLite now has official foreign key support.

What version of the product are you using? On what operating system?
1.9.1 on Windows 7 32bit with php 5.3.6

Reported by on 2012-01-12 21:08:40

Comments (14)

  1. Former user Account Deleted

    ``` Just realized this might be very tricky to implement. In SQLite foreign keys are disabled by default after opening any connection. You need to do 'PRAGMA foreign_keys = on' each time.

    Phpliteadmin does not keep a connection open between request. Therefore it would have to rememeber to do 'PRAGMA foreign_keys = on' for each request . ```

    Reported by `jos.grootlipman` on 2012-04-28 14:57:22

  2. Former user Account Deleted

    ``` How is this tricky? Just execute 'PRAGMA foreign_keys = on' in Database::construct after you open the database.....


    Reported by `` on 2012-04-28 20:45:51

  3. Former user Account Deleted

    ``` That would work but then it would *always* be on and no longer an option. On the other hand, I think very few would want it to be *off* ```

    Reported by `jos.grootlipman` on 2012-04-29 14:34:21

  4. Former user Account Deleted

    ``` Yes I noticed this as well, as I use FOREIGN KEYS in most of my databases it would be great to include this. Just trying to think how this should look. I think a simple drop down with all tables and columns would be pretty effective if placed within the table create action at the end of each table. ```

    Reported by `` on 2012-09-06 21:14:05

  5. Christopher Kramer

    ``` Very important issue in my opinion. I am currently working on other issues, but after that I might implement this. ```

    Reported by `crazy4chrissi` on 2012-10-06 23:03:35 - Status changed: `Accepted` - Labels added: Type-Enhancement, Priority-High - Labels removed: Type-Defect, Priority-Medium

  6. Former user Account Deleted
    As mentioned by jos.gross, On each connection to the database you have to issue "PRAGMA
    foreign_keys = ON;" for that connection to the database follow the foreign key constraints.
    And as Jeroen said we are going to have to add a line the execs right after the connection
    to enable it. Kinda sucks, but is a necessary evil. I will submit a patch later on
    that includes this "fix".

    Reported by on 2013-05-25 06:37:36

  7. Christopher Kramer
    Issue 217 has been merged into this issue.

    Reported by crazy4chrissi on 2013-12-25 16:19:48

  8. Christopher Kramer

    Reported by crazy4chrissi on 2014-01-02 12:40:04 - Labels added: Target-1.9.6 - Labels removed: Target-1.9.5

  9. Christopher Kramer

    Added the PRAGMA in rev. 603ac86a6b65. I think it's not much use to disable foreign key support, so we now always enable it. Anybody disagreeing please tell us why.

  10. Log in to comment