Having issue editing with phpgrid against a local data array

QuestionsHaving issue editing with phpgrid against a local data array
Johnny asked 7 years ago

Hi,

I'm able to show my data in the grid when going against a local data array, but when I bring up the edit form, change a value, and then click submit, I get this error:

Couldn't execute query. No database selected – UPDATE Array SET `bom`='11274',<a lot more columns so removed> WHERE `id` IN ('1021432')

I couldn't find much when using the local data array as a source on how to set he PHPGRID_* constants, and I have them set this way:

define("PHPGRID_DBTYPE","mysqli");
define("PHPGRID_DBHOST","localhost");
define("PHPGRID_DBUSER","dev");
define("PHPGRID_DBPASS","dev");
define("PHPGRID_DBNAME","");

So I thought, ok, I basically had to set PHPGRID_DBNAME to a value, but what since I'm not using a database? Here's my setup:

$db_conf = array(
"type" => PHPGRID_DBTYPE,
"server" => PHPGRID_DBHOST,
"user" => PHPGRID_DBUSER,
"password" => PHPGRID_DBPASS,
"database" => PHPGRID_DBNAME
);
// pass connection array to jqgrid()
$g = new jqgrid($db_conf);

// set few params
$grid["caption"] = "Test Grid";
$grid["autowidth"] = true;
$grid["sortable"] = true;
$g->set_options($grid);

// set database table for CRUD operations
$g->table = $json_table;

// render grid and get html/js output
$out = $g->render("id");
I tried setting PHPGRID_DBNAME to the table name since there is no database, e.g., to $json_table
$db_conf = array(
"type" => PHPGRID_DBTYPE,
"server" => PHPGRID_DBHOST,
"user" => PHPGRID_DBUSER,
"password" => PHPGRID_DBPASS,
"database" => $json_table
);
The error was a little different, because it still gives the "Couldn't execute query" message but without the "No database selected", so apparently still not correct. What am I missing?

Thanks,

Johnny.

Your Answer

13 + 18 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

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

Let us improve this post!

Tell us how we can improve this post?