Hello and thanks for this nice script,
I´ve got some issues here using your jsgrid-php-script. The json output of my /items/ doesn´t work when I select no filter option - I expect an output of all db-entries. First of all I have no clients and countries but items and places :-). I think the problem is my getAll-Method, because it seems that the filter is used anytime although I do not choose a filter.
$sql = "SELECT * FROM items WHERE
item_id LIKE :item_id AND
item_active LIKE :item_active AND
(item_place = 0 OR item_place = :item_place) AND
(item_sort = 0 OR item_sort = :item_sort) AND
(item_type = 0 OR item_type = :item_type) AND
item_description LIKE :item_description AND
item_adddesc LIKE :item_adddesc AND
item_amount LIKE :item_amount AND
item_pallets LIKE :item_pallets AND
item_sheetperpallet LIKE :item_sheetperpallet AND
item_width LIKE :item_width AND
item_height LIKE :item_height AND
item_weight LIKE :item_weight AND
(item_run = 0 OR item_run = :item_run) AND
item_time LIKE :item_time AND
item_aunumber LIKE :item_aunumber AND
item_arrival LIKE :item_arrival AND
(item_machine = 0 OR item_machine = :item_machine) AND
(item_keyaccount = 0 OR item_keyaccount = :item_keyaccount) AND
item_parents LIKE :item_parents;";
$q = $this->db->prepare($sql);
$q->bindParam(":item_id", $item_id);
$q->bindParam(":item_active", $item_active);
$q->bindParam(":item_place", $item_place);
$q->bindParam(":item_sort", $item_sort);
$q->bindParam(":item_type", $item_type);
$q->bindParam(":item_description", $item_description);
$q->bindParam(":item_adddesc", $item_adddesc);
$q->bindParam(":item_amount", $item_amount);
$q->bindParam(":item_pallets", $item_pallets);
$q->bindParam(":item_sheetperpallet", $item_sheetperpallet);
$q->bindParam(":item_width", $item_width);
$q->bindParam(":item_height", $item_height);
$q->bindParam(":item_weight", $item_weight);
$q->bindParam(":item_run", $item_run);
$q->bindParam(":item_time", $item_time);
$q->bindParam(":item_aunumber", $item_aunumber);
$q->bindParam(":item_arrival", $item_arrival);
$q->bindParam(":item_machine", $item_machine);
$q->bindParam(":item_keyaccount", $item_keyaccount);
$q->bindParam(":item_parents", $item_parents);
$q->execute();
$rows = $q->fetchAll();
$result = array();
foreach ($rows as $row) {
array_push($result, $this->read($row));
}
return $result;
}`
Hello and thanks for this nice script, I´ve got some issues here using your jsgrid-php-script. The json output of my /items/ doesn´t work when I select no filter option - I expect an output of all db-entries. First of all I have no clients and countries but items and places :-). I think the problem is my getAll-Method, because it seems that the filter is used anytime although I do not choose a filter.
Part of ItemRepository.php ` public function getAll($filter) { $item_id = "%" . $filter["item_id"] . "%"; $item_active = "%" . $filter["item_active"] . "%"; $item_place = $filter["item_place"]; $item_sort = $filter["item_sort"]; $item_type = $filter["item_type"]; $item_description = "%" . $filter["item_description"] . "%"; $item_adddesc = "%" . $filter["item_adddesc"] . "%"; $item_amount = "%" . $filter["item_amount"] . "%"; $item_pallets = "%" . $filter["item_pallets"] . "%"; $item_sheetperpallet = "%" . $filter["item_sheetperpallet"] . "%"; $item_width = "%" . $filter["item_width"] . "%"; $item_height = "%" . $filter["item_height"] . "%"; $item_weight = "%" . $filter["item_weight"] . "%"; $item_run = $filter["item_run"]; $item_time = "%" . $filter["item_time"] . "%"; $item_aunumber = "%" . $filter["item_aunumber"] . "%"; $item_arrival = "%" . $filter["item_arrival"] . "%"; $item_machine = $filter["item_machine"]; $item_keyaccount = $filter["item_keyaccount"]; $item_parents = "%" . $filter["item_parents"] . "%";
This is the part of my items/index.php:
switch ($_SERVER["REQUEST_METHOD"]) { case "GET": $result = $items->getAll(array( "item_id" => $_GET["item_id"], "item_active" => $_GET["item_active"], "item_place" => intval($_GET["item_place"]), "item_sort" => intval($_GET["item_sort"]), "item_type" => intval($_GET["item_type"]), "item_description" => $_GET["item_description"], "item_adddesc" => $_GET["item_adddesc"], "item_amount" => $_GET["item_amount"], "item_pallets" => $_GET["item_pallets"], "item_sheetperpallet" => $_GET["item_sheetperpallet"], "item_width" => $_GET["item_width"], "item_height" => $_GET["item_height"], "item_weight" => $_GET["item_weight"], "item_run" => intval($_GET["item_run"]), "item_time" => $_GET["item_time"], "item_aunumber" => $_GET["item_aunumber"], "item_arrival" => $_GET["item_arrival"], "item_machine" => intval($_GET["item_machine"]), "item_keyaccount" => intval($_GET["item_keyaccount"]), "item_parents" => $_GET["item_parents"] )); break; [...]
The Request URL shows up like this: Request URL: http://dev.test.default/items/?item_parents=&item_place_id=0&item_sort_id=0&item_type_id=0&item_description=&item_adddesc=&item_run=0&item_keyaccount=0&item_aunumber=&item_arrival=&item_machine_id=0&item_time=
With a JSON result of [] :-(
I tried several manipulations, but I do not find the mistake...Here´s my JS as well:
`$(function () {
});`
It would be nice, if you could help me in some way. THx Dominik