How do I generate my own table views and CRUD?

How do I generate my own table views and CRUD?

ThunderPoetThunderPoet Posts: 3Questions: 1Answers: 0

I've had tons of experience, many years of working with CRUD generators, and also refining code or manually assembling php, mysql, js code to pull data into views or to delete, update, insert & save data.

I bought the EDITOR 1.5.1 a couple of days ago and I am missing something, namely how to start working with my own tables.

I assumed that the "Generator" online at datatables.net was a simple version of the same Editor that would be included in the whole Editor product when purchased.

I have connected to my localhost database, used the mysql file to create the required tables for the demonstrations.

Now I need to move on and start working with My data.

There is no counterpart form to "Generate" or pull up my own tables in this same database.

I cannot imagine that the intention is that I have to manually edit the examples code for each table I wish to work with.

So, the Documentation rushes on to dive into a million things but skims lightly over the Editor function for a Developer.

Where is this form that creates scripts for each table and allows me to apply jquery options to the fields for display & online actions?

Thanks for helping me get to this next stage!

Answers

  • allanallan Posts: 61,611Questions: 1Answers: 10,089 Site admin

    Hi,

    Editor is a product for developers that requires code to be written that interfaces with its API. Generator is a quick start tool that will let you enter basic information about your tables and produce code for you. It is important to highlight that it is a quick start tool only - it does not offer a number of the advanced features of Editor such as joined fields, conditional queries, etc.

    There is no "offline" version of Generator, nor is there a GUI tool (other than Generator) that will produce the Editor code for you. To get the most from Editor you need to work with its APIs.

    Does that clarify the situation for you?

    Regards,
    Allan

  • ThunderPoetThunderPoet Posts: 3Questions: 1Answers: 0
    edited October 2015

    Thank you for taking the time, Allan.

    I have discovered the PHP script option and if I understand correctly that is where the whole process starts.

    2 things I would really recommend in the Documentation:

  • allanallan Posts: 61,611Questions: 1Answers: 10,089 Site admin
    edited October 2015

    Hi,

    I'm sorry to hear that the package doesn't meet your expectations.

    So, how do I "work with the API's" in my edition of Editor?

    You would open a code editor. Generator simply produces some very simple code as a starting point. You would then built on that as you require. The software is designed to be coded with, it is not a GUI CRUD builder.

    edit - the above post was edited so my reply don't entirely make sense now

    Allan

  • ThunderPoetThunderPoet Posts: 3Questions: 1Answers: 0
    edited October 2015

    Allan, again thank you for taking the time to answer!

    What I have just discovered is using the online Generator to create the PHP code!

    Instead of going down the path of assembling the whole package of downloads for one table in all its uses I selected the Download PHP option.

    Apparently what it gave me is the script that I should be using in "Editor.php"

    From that example I can see how to build an Editor instance for one table and can use the same example to manually create the code for the other tables.

    I have not run this yet, but I have seen how it compares to the default Editor.php and this seems to be the place.

    Assuming this is the place to start I would highly recommend updating your online documentation in 2 ways:

    1) HIGHLIGHT a Heading saying something like "If you are going to connect to your database with PHP follow these steps to Create your Own Views and Forms"

    2) After using the Generator for just one of your tables then Select the PHP button to create the code that will replace the code in Editor.php

    3) After updating the Editor.php code, leaving no empty lines and Not Closing the <?php statement you should be ready to use the API's for your own tables.

    4) You can either return to the Generator tool to generate PHP Editor code for each of your other tables or use the one example to create more instances manually of each table view to add to your Editor.php file.

    And Allan, here is an example Editor.php for one of my own tables

    // Build our Editor instance and process the data coming from _POST
    Editor::inst( $db, 'apotheken', 'apothekenid' )
        ->fields(
            Field::inst( 'sap' ),
            Field::inst( 'hautb' ),
            Field::inst( 'aussendients' ),
            Field::inst( 'exclusiv' ),
            Field::inst( 'klass' ),
            Field::inst( 'apotheke' ),
            Field::inst( 'adresse' ),
            Field::inst( 'plz' ),
            Field::inst( 'ort' ),
            Field::inst( 'kontakt' ),
            Field::inst( 'telefon' ),
            Field::inst( 'e-mail' ),
            Field::inst( 'kosmetikstudio' ),
            Field::inst( 'bemerkung' ),
            Field::inst( 'submitime' ),
            Field::inst( 'lastchange' )
        )
        ->process( $_POST )
        ->json(); 
    

    Allan, to add another instance is it like this, keeping the ->process( $_POST )
    ->json(); to process immediately after each instance?

    Editor::inst( $db, 'apotheken', 'apothekenid' )
        ->fields(
            Field::inst( 'sap' ),
            Field::inst( 'hautb' ),
            Field::inst( 'aussendients' ),
            Field::inst( 'exclusiv' ),
            Field::inst( 'klass' ),
            Field::inst( 'apotheke' ),
            Field::inst( 'adresse' ),
            Field::inst( 'plz' ),
            Field::inst( 'ort' ),
            Field::inst( 'kontakt' ),
            Field::inst( 'telefon' ),
            Field::inst( 'e-mail' ),
            Field::inst( 'kosmetikstudio' ),
            Field::inst( 'bemerkung' ),
            Field::inst( 'submitime' ),
            Field::inst( 'lastchange' )
        )
        ->process( $_POST )
        ->json();
    
    Editor::inst( $db, 'trainers', 'trainerid' )
        ->fields(
            Field::inst( 'firstname' ),
            Field::inst( 'lastname' ),
            Field::inst( 'username' ),
            Field::inst( 'password' )
        )
        ->process( $_POST )
        ->json();
    
  • allanallan Posts: 61,611Questions: 1Answers: 10,089 Site admin

    Thanks for the feedback! I will look at how I can improve the documentation in that regard.

    to add another instance is it like this, keeping the ->process( $_POST ) ->json(); to process immediately after each instance?

    Unless you add additional logic you would need a different PHP file for each table. The additional logic would just be a GET parameter or similar with so if statements to determine which Editor instance should be used for the request, but the principle is the same for all tables - you create it, assign the files, processing the data and then return the JSON to the client.

    Allan

This discussion has been closed.