I can tell you there is really nothing to the PHP I did for that one. In fact this does it all. I could easily do a add new record, but then I would have to work on my datagrid component also.
[script]
class people extends PHPRemoting
{
function people() {
$this->db = mysql_connect(DBHOST,DBUSER,DBPASS);
mysql_select_db(DBNAME);
$this->PHPRemoting();
// $this->_setReturnType("updatePerson","string");
}
function getPersonById($id) {
return mysql_query("SELECT * from test WHERE id = ".$id);
}
function getCityList()
{
$sql = "SELECT DISTINCT City from test ORDER by City";
return mysql_query($sql);
}
function updatePerson($obj)
{
$sql = "UPDATE test set ";
$a = array();
foreach($obj as $key => $val) {
if ($key != 'id' && $key != '__ID__') {
$a[] = "$key = '".addslashes($val)."'";
}
}
$sql .= implode(",", $a);
$sql .= " WHERE id = ".$obj['id'];
$q = mysql_query($sql);
if(mysql_affected_rows())
{
return "Record updated successfully";
}
else
{
return "Error updating record";
}
}
function getPeopleByCity($City, $fields) {
$sql = "SELECT ";
if(!is_array($fields)) {
$sql .= "*";
}
else {
$sql .= implode(",", $fields);
}
$sql .= " from test WHERE City = '".$City['City']."'";
return mysql_query($sql);
}
}
?>
[/script]