Adds Foreign Key Support.

Issue #217 duplicate
Former user created an issue

Originally reported on Google Code with ID 217

Adds foreign key support by turning foreign_keys pragma to on after the initial database
connection. This PRAGMA statement should be ignored by SQLite databases less then 3.6.19.

http://www.sqlite.org/foreignkeys.html#fk_enable

Reported by Dygear on 2013-05-25 07:45:37

<hr> * Attachment: phpliteadmin.php.patch

Comments (4)

  1. Christopher Kramer
    Well, first of all, I guess we should make this at least configurable. There is a reason
    why SQLite does not turn this on by default (backward compatibility). We can turn it
    on by default, but we should at least provide an option to turn it off.
    
    And of course this is only the starting point. Real foreign key support for phpLiteAdmin
    would mean that foreign key relationships could be created via GUI when creating or
    altering a table, that you could pick possible values of foreign keys via a dropdown
    menu when inserting or updating rows and so on.
    
    But yes, I guess we should at least start with this PRAGMA.
    

    Reported by crazy4chrissi on 2013-06-04 21:18:48 - Status changed: Accepted - Labels added: Type-Enhancement - Labels removed: Type-Patch

  2. Former user Account Deleted
    That's the odd thing about FK support within SQLite. There is really no direct way to
    detect it from what I'm seeing. We'd have to call #PRAGMA compile_options; and then
    parse it to see that it does not have OMIT_FOREIGN_KEY set. That's the hacky solution
    that I can see, if you know of a direct yes / no please do let me know.
    

    Reported by Dygear on 2013-06-04 22:00:54

  3. Christopher Kramer
    Well, detecting if FK support is at least available does not really help us. Because
    by default, FK support is disabled and people might use a db where FK constraints are
    defined but they don't want them to be enforced. Of course it does not make any sense
    to define FK constraints and not use them, but people might do so and rely on the fact
    that SQLite does not enforce them by default.
    
    Checking whether FK support is available in the SQLite library is not really necessary
    as I think the PRAGMA does not do any harm if it is not available.
    

    Reported by crazy4chrissi on 2013-06-05 07:28:18

  4. Log in to comment