Login   Register  
PHP Classes
elePHPant
Icontem

File: sample.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Bryan  >  PHP Class Generator Bryan Version  >  sample.php  >  Download  
File: sample.php
Role: Example script
Content type: text/plain
Description: sample.php
Class: PHP Class Generator Bryan Version
Generate classes to manipulate MySQL table rows
Author: By
Last change:
Date: 2010-08-20 08:41
Size: 773 bytes
 

Contents

Class file image Download
<?php 
include('class.Users.php');

// count all users
$count Users::doCount();
echo 
"COUNT " $count;

// select all users
$userlist Users::selectAll();
if (
$userlist)
{
  foreach(
$userlist as $user){
    echo 
$user->toString();
    
// update the value of user
    
$user->setPassword("new password");
    
$user->update();
    
    
// delete the current user
    
$user->delete();
  }
}else
{
  echo 
"User has no data";  
}

// insert a record
$user = new Users();
$user->setFirstname('Firstname');
$user->setLastname('Lastname');
$user->setUsername('Username');
$user->setPassword('Password');
$user->insert();
// retrieve the inserted user
$id $user->getId();

$userload Users::selectOne($id);
echo 
$userload->toString();

?>