Ejemplo n.º 1
0
// Retrieve all the data from the "example" table
$myQuery = "SELECT * FROM tblorders WHERE CustomerID=" . $customerID . " ORDER BY " . $sortColumn . " " . $sortDirection . " LIMIT " . $ordinalStart . "," . $pageSize . ";";
$result = mysql_query($myQuery) or die(mysql_error());
$countQuery = "SELECT COUNT(*) AS totalRowCount FROM tblorders where CustomerID=" . $customerID;
$totalRows = mysql_result(mysql_query($countQuery), 0);
//*******************************************************************
//Lets set up the output
//*******************************************************************
$getHandler = new EBAGetHandler();
//First we define the columns we are sending in each record, and name each field.
//We will do this by using the EBAGetHandler_DefineField function. We will name each
//field of data after its column name in the database.
$getHandler->DefineField("ProductName");
$getHandler->DefineField("OrderDate");
$getHandler->DefineField("ShippedDate");
$getHandler->DefineForeignKey("CustomerID");
$getHandler->DefineForeignKeyValue($customerID);
// *******************************************************************
// Lets loop through our data and send it to the grid
// *******************************************************************
$nrows = mysql_num_rows($result);
for ($counter = 0; $counter < $nrows; $counter++) {
    $row = mysql_fetch_array($result);
    $record = new EBARecord($row["OrderID"]);
    $record->add("OrderID", $row["OrderID"]);
    $record->add("ProductName", $row["ProductName"]);
    $record->add("OrderDate", $row["OrderDate"]);
    $record->add("ShippedDate", $row["ShippedDate"]);
    $getHandler->add($record);
}
$getHandler->SetTotalRowCount($totalRows);