PHP Classes

File: sample.php

Recommend this page to a friend!
  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: 11 years ago
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();

?>

For more information send a message to info at phpclasses dot org.