Skip to content

Cruddiy: table relationship support via foreign keys

Read here what Cruddiy is and what it can do for you: here is the code.

TLDR: Cruddiy is no-code Bootstrap 4 PHP form builder for MySQL tables.

I started Cruddiy when the Covid-19 lockdowns happened this spring, to keep me busy. And I released it on GitHub. After 25 stars 🤩 and 13 forks on GitHub and a couple of really encouraging messages on the original Cruddiy post, I thought it was time for an update.

🥳 Cruddiy now supports table relationships via foreign keys. 🥳

This means:

  • You can add new or delete existing table relations by picking columns that have a foreign key relation.
  • You can add specific actions for each table relation, like:
    • ON UPDATE : CASCADE / SET NULL / RESTRICT
    • ON DELETE: CASCADE / SET NULL / RESTRICT
  • Picking specific actions will result in different behavior. Please read up what these mean (mostly you want ON UPDATE CASCADE and ON DELETE CASCADE).

Having table relations in place wil have the following results for Cruddiy:

  • On the Create form the field will be populated with the correct key information.
  • On the Update form: the correct stored value will be preselected but you can still choose (update) different values from the select list.

Note 1: the table relationship builder is the first step in the Cruddiy CRUD creation process. However it is completely safe to ignore this step and move to the next step! I would even strongly advise doing so if you are not sure what you need to do, because it might break things. Also if you just want one or a couple of simple unrelated forms it is perfectly safe to skip this step.

Note 2: the table relationship builder is of course just a GUI for something you can also do in PHPMyAdmin or MySQL from the commandline. However, Cruddiy makes it visible and easier to work with table relations.

Some screenshots:

Table relation builder. One existing relation. And a couple of dropdown lists to create new ones. Feel free to skip this step by hitting ‘Continue CRUD Creation Process’.
In the column form columns with foreign keys are indicated by the blue icon.
A simple two field table. As you can see the second item is preselected (as it should be). However it is still possible to select a different value.

6 thoughts on “Cruddiy: table relationship support via foreign keys”

  1. This is excellent work for its simplicity compared to the commercial scripts and their bloat. That said, a few features such as making form fields changeable would make this A++. I found one seeming glitch in that when I connected to a database with 18 tables, all the dashboard links were created but one button didn’t display its text although it correctly navigated to the correct CRUD page.

    Thanks a million Jan van den Berg.

    1. Thanks for the nice comments Mark! I’ll have to look into the ‘glitch’ (I have never tested it with 18 tables before).
      I am not sure what you with ‘making form field changeable’: the form fields are based on the database column types, I suspect making those changeable could possibly break the database and/or queries.

  2. Good day. Great application – bravo, but when trying to edit data, an error occurs in the call stack – ( ! ) Fatal error: Uncaught Error: call to undefined function mysqli_stmt_get_result()
    function – newrelic_exception_handler
    and when trying to view (eye link) an error occurs – ( ! ) Fatal error: Uncaught Error: call to undefined function mysqli_stmt_get_result()
    function – newrelic_exception_handler
    Your work is a great help for codeless programming.
    Thank you very much for having such a program.
    Please help to fix it.

  3. This is a great little script. I had to make some mods to the generated code add columns with join tables, amongst a few other things. But it gives some decent code to get a good head start and takes away so much of the dreary coding. So easy and modular. For relatively simple crud stuff, this is the best tool around. And so easily modifiable.

  4. This is great work. One comment. On tables related with foreign keys (id, name), the display of source table shows ids and not names. The dropdowns works fine. Any way to fix that?

Leave a Reply

Your email address will not be published. Required fields are marked *