I am having trouble getting a custom update event to work with my grid. I'm using mysqli and the mysqli_query command requires a $connection as the first parameter, followed by the sql to execute as the second parameter. For example:
$result1=mysqli_query($connection,"UPDATE tbluser SET UserFirstName='xxx' WHERE idtblAdminUser = y");
What should I use as the $connection parameter? I am connecting to the database using:
$db_conf = array();
$db_conf["type"] = "mysqli";
$db_conf["server"] = $hostname_TW; // or you mysql ip
$db_conf["user"] = $username_TW; // username
$db_conf["password"] = $password_TW; // password
$db_conf["database"] = $database_TW; // database
// include and create object
include("/phpGrid/lib/inc/jqgrid_dist.php");
$g = new jqgrid($db_conf);
Can you provide a working example of a custom update grid event using mysqli please?
Thanks,
Cliff
Hello,
You can make g rid object as global var inside function.
$grid = new jqgrid();
And inside your callback handler:
global $grid;
$grid->execute_query("YOUR-SQL");
This will use existing connection to run query. You can also check 'execute_query' function code inside jqgrid_dist.php
Wow, that's a very fast response – thank you! I'll give it a try and let you know if I'm still struggling.
Thanks,
Cliff
You can use,
global $grid;
$result = $grid->execute_query($sql);
$arr = $result->GetRows();
Basically, it return adodb recordset object. api can be checked from adodb docs:
http://phplens.com/lens/adodb/docs-adodb.htm
Hello. I have a similar problem. What happen when the slq sentences returns values?.
When I try to use execute_query(), i get below error,
'Call to a member function execute_query() on a non-object'
$g6 = new jqgrid();
function check_total_2($data6)
{
global $g6;
$check_sql = "CALL sp_getStudentDataAjax('{$data6["params"]["student_user_id"]}','{$data6["params"]["testid"]}')";
$rs = $g6->execute_query($check_sql);
$r = $rs->GetRows($rs);
}