Author Topic: Inline Editing Example and Postgres  (Read 4120 times)

mjg77025

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 11
    • View Profile
Inline Editing Example and Postgres
« on: December 31, 2014, 01:04:59 am »
I am attempting the inline row editing example on the demos page and I'm getting the following response

{"data":[]}  followed by an empty grid.

The only code I have changed is in the PDO portion of the PHP code and the relevant PHP portions in the JS

Here is what I have changed in the PHP:

    if (isset($_SESSION["Products"])==false)
    {
        //add in session["Products"];
        $sql = "Select ProductID, ProductName, QuantityPerUnit, UnitPrice, UnitsInStock, Discontinued from products";
        $dbh = new PDO("pgsql:host=localhost;dbname=fredhost;user=control;password=remotexxx;port=5432");
        $stmt = $dbh->prepare($sql);
        $stmt->execute();
        $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
 
        $_SESSION["Products"]= json_encode($rows);
    }   

Any reason why I am not getting any data?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Inline Editing Example and Postgres
« Reply #1 on: December 31, 2014, 12:19:36 pm »
Just ensure the correct dbname and table name and print_r the $rows before hooking your code with pqgrid.

$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
print_r ( $rows );

if print_r works correctly ( displays rows ), then check the session

and verify the output of

echo $sb

http://paramquery.com/pro/products/getP?pq_datatype=JSON&pq_curpage=1&pq_rpp=10&_=1420008407223

mjg77025

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Inline Editing Example and Postgres
« Reply #2 on: January 02, 2015, 02:39:38 pm »
I got the test script to output data and now after I have corrected my PDO I get this:

{"data":[{"ProductID":1,"ProductName":"test","QuantityPerUnit":1,"UnitPrice":1,"UnitsInStock":1,"Discontinued":"true"},{"ProductID":2,"ProductName":"test2 ","QuantityPerUnit":1,"UnitPrice":2,"UnitsInStock":3,"Discontinued":"false"}]}

Followed by an empty grid.

Any thoughts?
« Last Edit: January 02, 2015, 03:02:52 pm by mjg77025 »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Inline Editing Example and Postgres
« Reply #3 on: January 02, 2015, 04:58:16 pm »
Please verify that you are pointing to correct url and check the response from server in getData callback.

getData: function (response) {
         alert( response );
         console.log( response );
         debugger;
         return { data: response.data };
}

and as you are not returning any paging information in the response, so remove pageModel or set pageModel: { type: 'local' }
« Last Edit: January 02, 2015, 05:00:09 pm by paramquery »

mjg77025

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Inline Editing Example and Postgres
« Reply #4 on: January 02, 2015, 05:31:24 pm »
Awesome!   Got it fixed!

I had deleted a character from the url in the javascript and that was causing my issues.

Are there any SQL examples available for the Update, Delete, and Edit functions?