ParamQuery grid support forum

General Category => ParamQuery Pro Evaluation Support => Topic started by: jaguar23 on October 04, 2017, 11:44:25 pm

Title: Data does not get saved to MySQL-DB
Post by: jaguar23 on October 04, 2017, 11:44:25 pm
Hi,

i want to build an inline editable grid with filters and frozen columns, is the connection of these features possible?

I started with the 'Auto Save' example and my MySQL table is showing nicely, but any edits I do are gone after page reload.
I don't get any errors in the web dev console and none in the apache log. How do you debug this kind of technology? (I am not a frontend dev obviously)

Regards,
J.
Title: Re: Data does not get saved to MySQL-DB
Post by: jaguar23 on October 05, 2017, 02:50:14 am
I got filtering and freezeCol to work too.
As far as I understand the PHP-code the addList, updateList and deleteList function do not write into the MySQL-table, which means they have to be implemented by hand?
Title: Re: Data does not get saved to MySQL-DB
Post by: jaguar23 on October 05, 2017, 07:23:23 pm
So far I came up with this code:

Code: [Select]
function deleteList($deleteList){
    foreach ($deleteList as $row)
    {
$primaryKey = $row["uid"];
$sql = "DELETE FROM MYTABLE WHERE uid='".$primaryKey."'";
$dsn = 'mysql:host='.DB_HOSTNAME.';dbname='.DB_NAME;
$options = array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
);
$dbh = new PDO($dsn, DB_USERNAME, DB_PASSWORD, $options);
$stmt = $dbh->prepare($sql);
$stmt->execute();
    }
    return $deleteList;
}

This does not work, the MySQL command does not even get triggered.
Can anybody explain to me, what I am getting wrong?
Title: Re: Data does not get saved to MySQL-DB
Post by: paramvir on October 05, 2017, 08:51:25 pm
Have you added this part. And were you able to debug your code. The deleteList function is called only when there are deleted records in the grid.

Code: [Select]
if( isset($_GET["pq_batch"]))   
{
    session_start();
    $dlist = $_POST['list'];
   
    if(isset($dlist["updateList"])){
        $dlist["updateList"] = updateList($dlist["updateList"]);
    }
    if(isset($dlist["addList"])){
        $dlist["addList"] = addList($dlist["addList"]);
    }
    if(isset($dlist["deleteList"])){
        $dlist["deleteList"] = deleteList($dlist["deleteList"]);
    }
   
    echo json_encode($dlist);

Title: Re: Data does not get saved to MySQL-DB
Post by: jaguar23 on October 05, 2017, 09:07:15 pm
Thank you very much for you answer!

Yes, that code is in there too, I took the Auto Save example code as template.
I am still not sure how to debug it best, I am watching the web dev console and the apache and mysql logs for now; since my MySQL code does not even get triggered, I assume that whole function does not get called, which means it fails at the code you posted or before...
Title: Re: Data does not get saved to MySQL-DB
Post by: jaguar23 on October 06, 2017, 01:08:34 am
I used the this template:
https://paramquery.com/pro/demos/editing_instant
Title: Re: Data does not get saved to MySQL-DB
Post by: linuxhong on December 29, 2017, 04:52:23 pm
Me too

I have a same problem... and I am a pro buyer

Please help me....
Title: Re: Data does not get saved to MySQL-DB
Post by: paramvir on December 29, 2017, 05:26:05 pm
It's expected that you have working knowledge of javascript/ jquery and php and bit familiar with debugging your code.

Please follow this example:

https://paramquery.com/pro/demos/editing_instant

In this example, lists are saved in session. You might need to change the code to save it in your database.

If you face issues, please mention all details and share your code / plnkr

https://plnkr.co/edit/zo6TdOvweAFvWM5JLasV?p=preview