datatable as input

datatable as input

LapointeLapointe Posts: 430Questions: 81Answers: 4

Hi

I thinks there is a bug in datatable as input.
When updating content,

Editor.field('DtAsInput').update( JSON );

if no option append set update append data to existing,

Editor.field('DtAsInput').update( JSON, true );

works for replace content...

Bob

This question has accepted answers - jump to:

Answers

  • LapointeLapointe Posts: 430Questions: 81Answers: 4
    edited April 2021

    DataTables 1.10.24
    Editor 2.0.1

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Answer ✓

    Thank you - it’s something I’ve got fixed in the 2.0.2 dev version and will be release as 2.0.2 this coming week.

    Allan

  • LapointeLapointe Posts: 430Questions: 81Answers: 4

    Hi Allan
    Thanks for that
    Today is sunday (in France).

    Just a question. I need to set some sql statement as

                    set @pivot = (
                        select group_concat(distinct
                        concat(
                            "sum(case when `Famille`='. "' , `Famille`, '" .' then `mt` end) as `", `Famille`, "`"
                            )
                        )
                        from totlignes
                    );
    
                    -- 2 set query SQL instruction
                    set @pivot = concat("select Prestation, ", @pivot, " from totlignes group by `Prestation`");
    
                    -- 3 prepared statement 
                    prepare stmt from @pivot;
    
                    -- 4 execute statement
                    execute stmt;
    
                    -- free sql memory
                    deallocate prepare stmt;
    
    

    Can you please help me to use the correct db-> function to do this and get data of course

  • LapointeLapointe Posts: 430Questions: 81Answers: 4

    For the inverted append flag, can you please tell me the code line to invert (else I'll have to change settings for many src files when 2.0.2 will come)
    Thanks again
    Tomorrow... Monday... For me working days are m to s included
    Bob

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    Hi Bob,

    Inside the _addOptions(conf, options, append = false) { function for the datatable type you will find:

    if (append) {
    

    It should be:

    if (! append) {
    

    For your SQL statements, can you remind me if you are using PHP or .NET - I can't remember I'm afraid. In either case though, I think for a more complex statement like that, you'd be best to use whatever database libraries you already have. For example in PHP you'd use the PDO object (which you can get from Editor's database libraries using $db->resource().

    Allan

  • LapointeLapointe Posts: 430Questions: 81Answers: 4

    Hi @allan

    Thanks for that...

    I use php, and find some stmt->prepare in your source code, but you have the complete db schema in mind, me not really (perhaps in 10 years ?)

    So if you can direct me using $db nor external connection declaration, it should be easyer to maintain.

    Thanks again.
    PS datatable as input just open amazing ways to UI.
    Bob

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Answer ✓

    Hi Bob,

    If you want to try using the PHP SQL abstraction library that we use in the Editor PHP libraries, they are fully documented here.

    You'll see there are methods such as ->insert() and ->update() for the basic SQL cases, and it makes that kind of thing a lot easier (imho). But for more complex statements, you will either want to do a raw query (->sql()) or use the PDO connection directly (->resource()).

    Allan

This discussion has been closed.