Fatal error: Call to a member function transaction() on a non-object in ...

Fatal error: Call to a member function transaction() on a non-object in ...

plepaingardplepaingard Posts: 5Questions: 0Answers: 0

Hi,

I have this error : Fatal error: Call to a member function transaction() on a non-object in ...

Can someone help me to fix this error?

My server source :

<?php

// DataTables PHP library

include("php/DataTables.php");

$table = 'myTable';
$db='myDB';
$primaryKey = "PrimaryKey";

$columns = array(
array( 'db' => 'id_ligne','dt' => 0 ),
array( 'db' => 'direction','dt' => 1 ),
array( 'db' => 'service','dt' => 2 ),
array( 'db' => 'fonction','dt' => 3 ),
array( 'db' => 'attribution','dt' => 4 ),
array( 'db' => 'numero', 'dt' => 5 ),
array( 'db' => 'materiel', 'dt' => 6 ),
array( 'db' => 'forfait', 'dt' => 7 ),
array( 'db' => 'options', 'dt' => 8 ),
array(
'db' => 'date_debut',
'dt' => 9,
'formatter' => function( $d, $row ) {
return date( 'd/m/y', strtotime($d));
}
),
array(
'db' => 'date_reforme',
'dt' => 10,
'formatter' => function( $d, $row ) {
return date( 'd/m/y', strtotime($d));
}
),
array( 'db' => 'reforme', 'dt' => 11 ),
array( 'db' => 'commentaire', 'dt' => 12 )

);

// SQL server connection information
$sql_details = array(
'user' => 'userName',
'pass' => 'password',
'db' => 'myDB',
'host' => 'localhost'
);

use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Options,
DataTables\Editor\Upload,
DataTables\Editor\Validate,
DataTables\Editor\ValidateOptions;

// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'myTable')
->fields(
Field::inst( 'id_ligne' ),
Field::inst( 'direction' ),
Field::inst( 'service' ),
Field::inst( 'fonction' ),
Field::inst( 'attribution' ),
Field::inst( 'numero' ),
Field::inst( 'materiel' ),
Field::inst( 'forfait' ),
Field::inst( 'options' ),
Field::inst( 'date_debut' ),
Field::inst( 'date_reforme' ),
Field::inst( 'reforme' ),
Field::inst( 'commentaire' )
)

->process( $_POST )
->json();

Thanks for your help.

Replies

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Looks like you are attempting to use both the SSP class and the Editor classes. Just use one - Use Editor if you are using Editor on the client-side.

    The specific issue you are seeing is because you are making the $db a string while the Editor class is expecting a Database class instance.

    Remove the SSP stuff and you should be okay.

    Allan

  • plepaingardplepaingard Posts: 5Questions: 0Answers: 0

    It's okay, i already fixed the problem, thanks you Allan.

    I have another error, Editor buttons (New, Edit, Delete) and search won't work. (even function like "rowCallback")

    I send you my script :

    ``
    var editor;

    $(document).ready(function() {

    editor = new $.fn.dataTable.Editor( {
        "ajax": "server_processing.php",
        "table": "#ligne_admin",
        "fields": [ {
                "label": "ID :",
                "name": "id_ligne"
            }, {
                "label": "Direction :",
                "name": "direction"
            }, {
                "label": "Service :",
                "name": "service"
            }, {
                "label": "Fonction :",
                "name": "fonction"
            }, {
                "label": "Attribution :",
                "name": "attribution"
            }, {
                "label": "Numéro :",
                "name": "numero"
            }, {
                "label": "Matériel :",
                "name": "materiel"
            }, {
                "label": "Forfait:",
                "name": "forfait"
            }, {
                "label": "Options :",
                "name": "options"
            }, {
                "label": "Date début :",
                "name": "date_debut",
                "type": "date"
            }, {
                "label": "Date réforme :",
                "name": "date_reforme"
            }, {
                "label": "Réforme :",
                "name": "reforme"
            }, {
                "label": "Commentaire :",
                "name": "commentaire"
            }
        ]
    } );
    
    // Activate an inline edit on click of a table cell
    

    /* $('#example').on( 'click', 'tbody td:not(:first-child)', function (e) {
    editor.inline( table.cell( this ).index(), {
    onBlur: 'submit'
    } );
    } );*/

    var table = $('#ligne_admin').DataTable( {
    
        lengthChange: false,
        "scrollY": 500,
        dom: "Bfrltip",
        select: true,        
        serverSide: true,
        processing: true,
        ajax: "server_processing.php",
        searching: true,
    
    
         "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
    
        select: {
            style:    'os',
            selector: 'td:first-child'
        },
    
        columns: [
            { data: "id_ligne" },
            { data: "direction" },
            { data: "service" },
            { data: "fonction" },
            { data: "attribution"},
            { data: "numero" },
            { data: "materiel" },
            { data: "forfait" },
            { data: "options"},
            { data: "date_debut"},
            { data: "date_reforme"},
            { data: "reforme"},
            { data: "commentaire"}
    
        ],
    
        order: [[ 0, 'asc' ]],
    
        select: true,
    
    
        buttons: [
            { extend: 'create', editor: editor },
            { extend: 'edit',   editor: editor },
            { extend: 'remove', editor: editor },
            {
                extend: 'collection',
                text: 'Export',
                buttons: [
                    'copy',
                    'excel',
                    'csv',
                    'pdf',
                    'print'
                ]
            }
        ],
    
    
        "rowCallback": function(row, data, index){
            if(data[11] === '0'){
                $('td:eq(11)', row).html('<span style="color: white;border-radius: 25px;background-color: #4CAF50;padding: 6px;padding-right: 15px;padding-left: 15px;">Active</span>');
            }
            if(data[11] === '1'){
                $('td:eq(11)', row).html( '<span style="color: white;border-radius: 25px;background-color: #f44336;padding: 6px;padding-right: 10px;padding-left: 10px;">Inactive</span>');
            }
        }
    } );
    

    } );``

    My import too :

        <link rel="stylesheet" type="text/css" href="css/bootstrap.css">
        <link rel="stylesheet" type="text/css" href="css/dataTables.bootstrap4.min.css">
        <link rel="stylesheet" type="text/css" href="css/buttons.bootstrap4.min.css">
        <link rel="stylesheet" type="text/css" href="css/select.bootstrap4.min.css">
        <link rel="stylesheet" type="text/css" href="css/editor.bootstrap4.min.css">
    


    <script type="text/javascript" language="javascript" src="js/jquery.dataTables.min.js"></script>
    <script type="text/javascript" language="javascript" src="js/dataTables.bootstrap4.min.js"></script>
    <script type="text/javascript" language="javascript" src="js/dataTables.buttons.min.js"></script>
    <script type="text/javascript" language="javascript" src="js/buttons.bootstrap4.min.js"></script>
    <script type="text/javascript" language="javascript" src="js/dataTables.select.min.js"></script>
    <script type="text/javascript" src="js/dataTables.editor.min.js"></script>
    <script type="text/javascript" src="js/editor.bootstrap4.min.js"></script>

        <script type="text/javascript" language="javascript" src="js/jszip.min.js"></script>
        <script type="text/javascript" language="javascript" src="js/pdfmake.min.js"></script>
        <script type="text/javascript" language="javascript" src="js/buttons.html5.min.js"></script>
        <script type="text/javascript" language="javascript" src="js/jszip.min.js"></script>
        <script type="text/javascript" language="javascript" src="js/buttons.print.min.js"></script>
    
        <script type="text/javascript" src="js/script.js"></script>
    

    Thanks you a lot for your help.

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Can you give me a link to the page showing the issue please? That looks like it should work okay.

    Allan

  • plepaingardplepaingard Posts: 5Questions: 0Answers: 0
    edited June 2018

    This is a link where you can see a screen of the different problems :

    https://ibb.co/gfUtS8

    • Case Search = Test don't do anything,

    • TypeError: c(...).one(...).appendTo(...).modal is not a function. When i click new Button, Edit or Delete.

    (Select a line works)

    More over, i don't understant why my table is not order by ID ( i guess that my script isn't fully used)

    Thanks again.

    Edit :

    Below my table : Showing 0 to 0 of 0 entries (filtered from NaN total entries)

  • plepaingardplepaingard Posts: 5Questions: 0Answers: 0

    I import

    <script type="text/javascript" language="javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/js/bootstrap.min.js"></script>
    

    that fix my editor buttons.

    Need responses for search, pagination, and modification in database please.

    Regards.

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    I'd really need a link to a page showing the issue I'm afraid. Have you included the Bootstrap 4 Javascript on your page?

    Allan

  • plepaingardplepaingard Posts: 5Questions: 0Answers: 0

    Hi,

    I started from scratch again and i solved my problems.

    I think it was a file tree problem.

    Thanks anyway for your help and availability!

This discussion has been closed.