jQWidgets Forums

jQuery UI Widgets Forums General Discussions PHP deprecated extensions

This topic contains 3 replies, has 2 voices, and was last updated by  Peter Stoev 12 years, 2 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • PHP deprecated extensions #19679

    DavidSimmons
    Participant

    Do you plan to update examples to incorporate php preparedStatements in the future. Most of your php mysql examples are using deprecated as of PHP 5.5.0. I know none of the php examples will run in my environment and have made learning from the examples difficult. I would be very curious how many users are using preparedStatements.

    PHP deprecated extensions #19683

    Peter Stoev
    Keymaster

    Hi David,

    What exactly is the issue on your side and which API is deprecated in PHP 5.5?

    Regards,
    Peter Stoev

    PHP deprecated extensions #19690

    DavidSimmons
    Participant

    Here are the deprecated extensions. They also suggest moving to PDOStatments which I have completely.

    mysql_query()
    mysql_fetch_assoc()
    mysql_num_rows()
    *******
    http://php.net/manual/en/function.mysql-num-rows.php
    Warning
    This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide and related FAQ for more information. Alternatives to this function include:

    mysqli_stmt_num_rows()
    PDOStatement::rowCount()

    ********

    The area I am having problems with are paging. Here is a small example. My problem seem to be pager callback if I am understanding everything. When clicking on the Previous Next buttons the callback is not triggered. I have tested the php by entering static variables to test each area.

    pager: function(pagenum, pagesize) {
    alert(pagenum + ‘ ‘ + pagesize);
    //$(jqxgrid).jqxGrid(‘updatebounddata’, pagenum, pagesize, oldpagenum);
    },

    0) {
    $pagenum = $_GET[‘pagenum’];
    }

    if (isset($_GET[‘pagesize’]) && $_GET[‘pagesize’] > 0) {
    $pagesize = $_GET[‘pagesize’];
    }

    $start = $pagenum * $pagesize;

    $table = “ProductLarge”;
    $sql = “SELECT ID, Product, Description, Cost, Markup FROM $table LIMIT $start, $pagesize”;

    if (isset($_GET[‘insert’])) {

    } else if (isset($_GET[‘update’])) {

    } else if (isset($_GET[‘delete’])) {

    } else if (isset($_GET[‘sortdatafield’])) {
    $sortfield = $_GET[‘sortdatafield’];
    $sortorder = $_GET[‘sortorder’];

    if ($sortfield != NULL) {
    if ($sortorder == “desc”) {
    $query = $sql . ” ORDER BY $sortfield DESC”;
    } else if ($sortorder == “asc”) {
    $query = $sql . ” ORDER BY $sortfield ASC”;
    }
    $preparedStatement = $conn->prepare($query);
    if ($preparedStatement->execute()) {
    $result = $preparedStatement->fetchAll();
    echo json_encode($result);
    } else {
    $results = array(“Success” => “false”, “Error” => “true”, “Message” => “Query Failed! “);
    die(json_encode($results));
    }
    }
    } else {
    $query = $sql;
    $preparedStatement = $conn->prepare($query);
    if ($preparedStatement->execute()) {
    $count = $preparedStatement->rowCount();
    $result = $preparedStatement->fetchAll();
    $data[] = array(
    ‘TotalRows’ => $count,
    ‘Rows’ => $result
    );
    echo json_encode($data);
    } else {
    $results = array(“Success” => “false”, “Error” => “true”, “Message” => “Query Failed! $query”);
    die(json_encode($results));
    }
    }
    ?>

    $(document).ready(function() {
    var theme = “energyblue”;
    var jqxgrid = “#jqxgridProductLarge”;

    var source = {
    datatype: “json”,
    cache: false,
    datafields: [
    {name: ‘ID’, type: ‘int’},
    {name: ‘Product’, type: ‘text’},
    {name: ‘Description’, type: ‘text’},
    {name: ‘Cost’, type: ‘float’},
    {name: ‘Markup’, type: ‘float’},
    {name: ”}//Place holder
    ],
    id: ‘ID’,
    url: ‘ProductLargeData.php’,
    root: ‘Rows’,
    beforeprocessing: function(data) {
    source.totalrecords = data[0].TotalRows;
    },
    addrow: function(rowid, commit) {

    },
    deleterow: function(rowid, commit) {

    },
    updaterow: function(rowid, rowdata, commit) {

    },
    filter: function(filters, recordsArray) {
    //alert(filters + ‘ ‘ + recordsArray);
    },
    //pagenum: 3,
    //pagesize: 20,
    pager: function(pagenum, pagesize) {
    alert(pagenum + ‘ ‘ + pagesize);
    //$(jqxgrid).jqxGrid(‘updatebounddata’, pagenum, pagesize, oldpagenum);
    },
    sort: function(column, direction) {
    //$(jqxgrid).jqxGrid(‘updatebounddata’, ‘sort’);
    }
    };

    var dataAdapter = new $.jqx.dataAdapter(source);

    $(jqxgrid).jqxGrid({
    theme: theme,
    width: ‘99.9%’,
    //height: 500,
    source: dataAdapter,
    pageable: true,
    pagesize: 20,
    showemptyrow: false,
    autoheight: true,
    virtualmode: true,
    scrollbarsize: 10,
    sortable: true,
    sorttogglestates: 1,
    altrows: true,
    enablehover: true,
    editable: true,
    filterable: true,
    selectionmode: “multiplecellsadvanced”,
    rendergridrows: function(params) {
    return params.data;
    },
    columns: [
    {text: ‘ID’, dataField: ‘ID’, width: 60, pinned: true, editable: false},
    {text: ‘Product’, datafield: ‘Product’, width: 180, editable: false},
    {text: ‘Description’, dataField: ‘Description’, width: 500, editable: false},
    {text: ‘Cost’, dataField: ‘Cost’, width: 160, editable: false},
    {text: ‘Markup’, dataField: ‘Markup’, width: 160, editable: false},
    {text: ”, dataField: ”, width: ‘100%’, editable: false}
    ]
    });
    });

    PHP deprecated extensions #19691

    Peter Stoev
    Keymaster

    Hi David,

    As these APIs are still available in PHP and most of the users still use them, the best we can do is to provide additional samples in the future versions, but we will also keep the current samples. For Paging, you may see the online and working sample with Server Paging.

    Regards,
    Peter Stoev

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.