Update with data processor

Good Evening,

I’ve used a sample code of dataprocessor in Grid and all work ok…



I need now to modify update process in order to update records in a table mysql with 2 primary key.



This is the default sample:



function update_row(){

    $sql =     “UPDATE samples_grid SET sales=’”.$_GET[“c0”]."’,

                title=        ‘".addslashes($_GET[“c1”])."’,

                author=        ‘".addslashes($_GET[“c2”])."’,

                price=        ‘".$_GET[“c3”]."’,

                instore=    ‘".$_GET[“c4”]."’,

                shipping=    ‘".$_GET[“c5”]."’,

                bestseller=    ‘".$_GET[“c6”]."’,

                pub_date=    ‘".$_GET[“c7”]."’

            WHERE book_id=".$_GET[“gr_id”];

    $res = mysql_query($sql);

    

    return “update”;    

}



My problem is that i have to pass to value in Where clause like this:



WHERE book_id=".$_GET[“gr_id”] AND employee_id=.$_GET["?"];



How can i find the right variable to pass?

Which code you are using for data loading in the grid?
Most probably you have something similar to the

echo '…row related data here …

which can be changed as
echo '$employee_id…row related data here …

now , on server side, for each update action you will receive $_GET[“employee_id”] with value of second key.

Yes the code has been posted on a Knowloedge Base:

<?php
//include db connection settings
//change this setting according to your environment
require_once("config.php");

//include XML Header (as response will be in xml format)
header("Content-type: text/xml");
//encoding may be different in your case
echo('<?xml version="1.0" encoding="iso-8859-1"?>’);
//start output of data
echo ‘’;

//output data from DB as XML
$sql = “SELECT  * from samples_grid”;
$res = mysql_query ($sql);
       
if($res){
    while($row=mysql_fetch_array($res)){
        //create xml tag for grid’s row
        echo ("<row id=’".$row[‘book_id’]."’>");
        print("");
        print("");
        print("");
        print("");
        print("");
        print("");
        print("");
        print("");
        print("");
    }
}else{
//error occurs
    echo mysql_errno().": “.mysql_error().” at “.LINE.” line in “.FILE.” file
";
}

echo ‘’;

?>

Not understand why grid_id and not book_id because grid_id its not part of mysql table.
after that my last quesion is: what about printing for example a&grave letttres? es:

if i wanted to print in xml content :

print("");
how should be the result code?

thank u for your next 2 answer.







//create xml tag for grid’s row
echo ("<row id=’".$row[‘book_id’]."’>");
print("".$row[‘employee_id’].""); //can be added , to have the employee_id on server side
print("");

>>Not understand why grid_id and not book_id because
gr_id is the name of parameter, which contains value of row@id , it doesn’t matter what field was used to fill this field.

>> what about printing for example a&grave letttres? es:
There is no any specific requirements from the grid’s side, but I’m not quite sure how MySQL handles the names with extended ASCII symbols. ( its fully depends on mysql|php implementation and not related to the grid’s functionality )
Personally, I suspect that mysql will convert name to valid ASCII, and data will be available as $row[‘Lunedi’] ( normal i )

if($res){
    while($row=mysql_fetch_array($res)){
        //create xml tag for grid’s row
        echo ("<row id=’".$row[‘emp_number’]."’>");
        echo ("<row id=’".$row[‘book_id’]."’>");
        print("".$row[‘employee_id’].""); ====> it gives me a syntax error why?
        print("");
        print("");
        print("");
        print("");
print("");
    }
}else{
//error occurs
    echo mysql_errno().": “.mysql_error().” at “.LINE.” line in “.FILE.” file
";
}

echo ‘’;

?>

Sorry , was a my error in the sample code.
It must be
print("<userdata name=employee_id>".$row[‘employee_id’].""); //quotes are escaped