File: /pages/tutorials/database/database-04.php
<?php class Database04 extends Page { public function InitializeComponent() { parent::$PAGE_TITLE = "Tutorial : Select query"; // init result table $this->render = new Table(); $this->render->setTitle( new Label(ucfirst(ProductDbTable::TABLE_NAME)." :", true)); $this->render->setId("product_table_2"); $this->render->addRowColumns( ProductDbTable::FIELD_PRODUCT_ID, ProductDbTable::FIELD_NAME, ProductDbTable::FIELD_PRICE) ->setHeaderClass(0); // execite select query $sql = new SqlDataView(new ProductDbTable()); $sql->setLimit(0, 100); $sql->setClause(ProductDbTable::FIELD_PRICE." > 0"); $it = $sql->retrieve(); while ($it->hasNext()) { $row = $it->next(); $this->render->addRowColumns( $row->getValue(ProductDbTable::FIELD_PRODUCT_ID), $row->getValue(ProductDbTable::FIELD_NAME), $row->getValue(ProductDbTable::FIELD_PRICE). " €"); } $this->render->activateAdvanceTable(); $this->render = new WSPObject($this->render, "<br/>"); } } ?>
Go back to tutorial of the componant Database
|