WebSite-PHP Framework PHP
Mehrsprachig
Einfacher Ajax Modus
Kein HTML, kein JavaScript
URL Rewriting
Mails senden
Sitemap - RSS - Web service
Laden Sie WebSite-PHP FrameWork jetzt herunter
 


Loading
 


Tutorial : Insert / Update / 
Delete customer

Tutorials

>

Tutorial Database

>

Tutorial : Insert / Update / Delete customer


Database-01: Tutorial der Komponente Database vom PHP FrameWork WebSite-PHP.

Tutorial : Insert / Update / Delete customer:

Customer :
customer_id : 10
name : Toto
address : 5th, street principal

customer_id : 10
name : Toto
address : 13th, street second


Zurück zum Tutorial der Komponente Database



Quelltext

Quelltext


Datei: /pages/tutorials/database/database-01.php

<?php
class Database01 extends Page {
    public function 
InitializeComponent() {
        
parent::$PAGE_TITLE "Tutorial : Insert / Update / 
                                Delete customer"
;
        
        
$this->render = new WSPObject();
        
DataBase::getInstance()->beginTransaction();
        
        
// Insert
        
$cutomer = new CustomerObj();
        
$cutomer->setName("Toto");
        
$cutomer->setAddress("5th, street principal");
        
$cutomer->save();
        
        
$this->render->add(new Label(
                
ucfirst(CustomerDbTable::TABLE_NAME), true), 
                
" :<br/>");
        
$this->render->add(CustomerDbTable::FIELD_CUSTOMER_ID":",
                        
$cutomer->getCustomerId(), "<br/>");
        
$this->render->add(CustomerDbTable::FIELD_NAME":"
                        
$cutomer->getName(), "<br/>");
        
$this->render->add(CustomerDbTable::FIELD_ADDRESS":"
                        
$cutomer->getAddress(), "<br/><br/>");
        
        
// Update
        
$cutomer_upd = new CustomerObj();
        
$cutomer_upd->load($cutomer->getCustomerId());
        
$cutomer_upd->setAddress("13th, street second");
        
$cutomer_upd->save();
        
        
$this->render->add(CustomerDbTable::FIELD_CUSTOMER_ID":",
                        
$cutomer_upd->getCustomerId(), "<br/>");
        
$this->render->add(CustomerDbTable::FIELD_NAME":"
                        
$cutomer_upd->getName(), "<br/>");
        
$this->render->add(CustomerDbTable::FIELD_ADDRESS":"
                        
$cutomer_upd->getAddress());
        
        
// Delete
        
$cutomer_upd = new CustomerObj();
        
$cutomer_upd->load($cutomer->getCustomerId());
        
$cutomer_upd->delete();
        
        
DataBase::getInstance()->commitTransaction();
        
        
$this->render = new WSPObject($this->render"<br/>");
    }
}
?>


Zurück zum Tutorial der Komponente Database


Tabellen

Tabellen


drop table if exists customer;

/*==============================================================*/
/* table: customer                                              */
/*==============================================================*/
create table customer
(
   customer_id          int not null  auto_increment,
   name                 varchar(50),
   address              varchar(100),
   primary key (customer_id)
) engine = innodb;


Share

 


Copyright © 2009-2024 WebSite-PHP Framework PHP
Start Dokumentation Herunterladen Schnellstart Tutorials Wiki Issue Tracker