To write your own insert/update/delete implementations, we use custom events that allows us to have our custom business case coding. We’ve added another helper function that will push your server side validation error to php grid, and display it as error dialog.

For example, if you have written your on_insert function, and want to validate that client does not already exist in database, you can write this code. It will prompt the ‘already exist’ message as data entry error.

The helper function name is ‘phpgrid_error’.

function add_client($data)
{
	$check_sql = "SELECT count(*) as c from clients where LOWER(`name`) = '".strtolower($data["params"]["name"])."'";
	
	$rs = mysql_fetch_assoc(mysql_query($check_sql));

	if ($rs["c"] > 0)
		phpgrid_error("Client already exist in database");

	mysql_query("INSERT INTO clients VALUES (null,'{$data["params"]["name"]}','{$data["params"]["gender"]}','{$data["params"]["company"]}')");
}

It is available in latest build, so eligible premium members can claim their copy.

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Leave a Reply