WebSite-PHP Framework PHP
Multi langues
Mode Ajax simple
Aucun HTML, aucun JavaScript
URL rewrinting
Envoi d'email
Sitemap - RSS - Web service
Télécharger le Framework WebSite-PHP maintenant
 


Loading
 


Tutorial : Select query

Tutoriels

>

Tutoriel Database

>

Tutorial : Select query


Database-04: Tutoriel du composants Database du FrameWork PHP WebSite-PHP.

Tutorial : Select query:

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



Retourner aux tutoriels du composants Database



Code source

Code source


Fichier: /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 Object($this->render"<br/>");
    }
}
?>


Retourner aux tutoriels du composants Database


Share

 


Copyright © 2009-2016 WebSite-PHP Framework PHP
Accueil Documentation Télécharger Quick start Tutoriels Wiki Issue Tracker