WebSite-PHP Framework PHP
Multi language
Simple Ajax mode
No HTML, no JavaScript
URL rewriting
Mail sending
Sitemap - RSS - Web service
Download WebSite-PHP FrameWork now
 


Loading
 


Tutorial : Select query

Tutorials

>

Tutorial Database

>

Tutorial : Select query


Database-04: Tutorial of the composant Database of the PHP FrameWork WebSite-PHP.

Tutorial : Select query:

product_id name price
1 Coca 0.5 €
2 Hamburger 5.2 €
3 Water 0.8 €
4 Milk 1 €



Go back to tutorial of the componant Database



Source code

Source code


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(0100);
        
$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).
                                                
" &euro;");
        }
        
$this->render->activateAdvanceTable();
        
        
$this->render = new WSPObject($this->render"<br/>");
    }
}
?>


Go back to tutorial of the componant Database


Share

 


Copyright © 2009-2024 WebSite-PHP Framework PHP
Home Documentation Download Quick start Tutorials Wiki Issue Tracker