Aggrid Php Example Updated _best_ Direct

on columns you sort/filter frequently:

INSERT INTO products (product_name, category, price, stock_quantity) SELECT CONCAT('Product ', SEQ), ELT(1 + FLOOR(RAND() * 5), 'Electronics', 'Clothing', 'Books', 'Toys', 'Furniture'), ROUND(RAND() * 500, 2), FLOOR(RAND() * 1000) FROM (SELECT @ROW := @ROW + 1 AS SEQ FROM information_schema.columns, (SELECT @ROW := 0) r LIMIT 100000) t; aggrid php example updated

$countSql = "SELECT COUNT(*) as total FROM products $where"; $totalRows = $pdo->query($countSql)->fetch(PDO::FETCH_ASSOC)['total']; $sql = "SELECT id, name, price FROM products $where $orderBy LIMIT $startRow, $limit"; $stmt = $pdo->query($sql); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); echo json_encode([ 'success' => true, 'rows' => $rows, 'lastRow' => $totalRows ]); catch(PDOException $e) echo json_encode(['success' => false, 'error' => $e->getMessage()]); on columns you sort/filter frequently: INSERT INTO products