Propozycja moja jest taka:
-Tworzysz sobie klase User, ktora zawiera takie pola jakie powinna miec.. dla przykladu pokaze jak ja tozrbilem:
<?php
class client
{
private $_sCompany;
private $_sStreet;
private $_sCity;
private $_sZipCode;
private $_iNip;
private $_sEmail;
private $_sPassword;
private $_sTelephone;
private $_iId;
private $_oMySQL;
private $_bNotification;
public function __construct($iClientId=null,$aClientData=null)
{
//if(!is_int($iClient))
//throw new CleintException('must be int');
if($iClientId != null)
{
$this->_iId = $iClientId;
require('_configure.php');
$this->_oMySQL = new DataBaseMySQL($aDBParams);
$this->_oMySQL->query("SELECT * from client where id='$iClientId'");
$aClientData = $this->_oMySQL->fetch();
}
$this->setCompany($aClientData['company']);
$this->setStreet($aClientData['street']);
$this->setCity($aClientData['city']);
$this->setZipCode($aClientData['zip']);
$this->setNip($aClientData['nip']);
$this->setEmail($aClientData['email']);
$this->setPassword($aClientData['password']);
$this->setTelephone($aClientData['telephone']);
$this->setNotification($aClientData['want_email']);
}
public function setCompany($sCompany)
{
$this->_sCompany = $sCompany;
}
public function setStreet($sStreet)
{
$this->_sStreet = $sStreet;
}
public function setCity($sCity)
{
$this->_sCity = $sCity;
}
public function setZipCode($sZip)
{
$this->_sZipCode = $sZip;
}
public function setNip($iNip)
{
$this->_iNip = $iNip;
}
public function setEmail($sEmail)
{
$this->_sEmail = $sEmail;
}
public function setPassword($sPassword)
{
$this->_sPassword = $sPassword;
}
public function setTelephone($sTelephone)
{
$this->_sTelephone = $sTelephone;
}
public function setNotification($bNotify)
{
$this->_bNotification = (int)(bool)(int)$bNotify;
}
public function getCompany()
{
return $this->_sCompany;
}
public function getStreet()
{
return $this->_sStreet;
}
public function getCity()
{
return $this->_sCity;
}
public function getZipCode()
{
return $this->_sZipCode;
}
public function getNip()
{
return $this->_iNip;
}
public function getEmail()
{
return $this->_sEmail;
}
public function getPassword()
{
return $this->_sPassword;
}
public function getTelephone()
{
return $this->_sTelephone;
}
public function getId()
{
return $this->_iId;
}
public function getNotification()
{
return $this->_bNotification;
}
public function getArrayed()
{
return array('email' => $this->_sEmail
, 'password' => $this->_sPassword,
'company' => $this->_sCompany,
'street' => $this->_sStreet,
'city' => $this->_sCity,
'zip' => $this->_sZipCode,
'nip' => $this->_iNip,
'telephone' => $this->_sTelephone,
'want_email' => $this->_bNotification);
}
public function update()
{
$oMySQL = $this->_oMySQL;
$oMySQL->update('client',$this->getArrayed(),"id='$this->_iId'");
}
public function delete()
{
$oMySQL = $this->_oMySQL;
$oMySQL->query("DELETE from client where id='$this->_iId'");
}
public function getReports()
{
$oReportCollectioner = new ReportCollectioner();
$oMySQL = $this->_oMySQL;
$oMySQL->query("SELECT id from report where client_id='$this->_iId'");
while($aRow = $oMySQL->fetch())
{
$oReportCollectioner->pushReport(new report($aRow['id']));
}
return $oReportCollectioner;
}
public function __toString()
{
return $this->_sCompany;
}
public function addSelf()
{
require('_configure.php');
$this->_oMySQL = new DataBaseMySQL($aDBParams);
$aClientData = $this->getArrayed();
$aClientData['id'] = null;
$this->_oMySQL->insert('client', $aClientData);
}
}
?>
W klasie tej uzylem Liba do laczenia z baza, zywcem z Rapide...
dalej mamy Client Collectioner:
<?php
class ClientCollectioner implements Iterator
{
private $_aClients;
private $_bValidIterationPointer = true;
public function __construct(){
$this->_aClients
= array(); }
{
$this->_bValidIterationPointer = true;
}
{
}
{
return key($this->_aClients
); }
{
if(next($this->_aClients
) === false) $this->_bValidIterationPointer = false;
else
$this->_bValidIterationPointer = true;
}
public function valid()
{
return $this->_bValidIterationPointer;
}
public function pushClient(client $oClient)
{
//sort($this->_aClients);
}
public function isFilled()
{
return count($this->_aClients
) != 0 ?
true : false; }
}
?>
i to wszystko, mozemy dodac klienta:
<?php
$aClientData = array('id' => null, 'email' => $_POST['email'],
'password' => md5($_POST['passwordfirst']), 'company' => $_POST['company'],
'street' => $_POST['street'],
'city' => $_POST['city'],
'zip' => $_POST['zip'],
'nip' => $_POST['nip'],
'telephone' => $_POST['telephone']);
$oClient = new Client(null,$aClientData);
$oClient->addSelf();
?>
edytowac:
<?php
$oClient = new Client($iId);
$oClient->setCompany($_POST['company']);
$oClient->setEmail($_POST['email']);
$oClient->setStreet($_POST['street']);
$oClient->setZipCode($_POST['zip']);
$oClient->setCity($_POST['city']);
$oClient->setNip($_POST['nip']);
$oClient->setTelephone($_POST['telephone']);
$oClient->update();
?>
lub usuwac:
<?php
$oClient = new Client($_GET['id']);
$oClient->delete();
?>
uff. mam nadzieje, ze zrozumiesz jak cos to sluze pomoca

ofc: co do client collectioner mozemy go uzupelnic:
<?php
$oClientCollectioner = Utils::fillUpClientCollectioner($_GET['p'],$_GET['k']);
?>
i podac do foreach:
<?php
foreach($oClientCollectioner as $oClient)
{
($styl=='nieparzysty')? $styl='parzysty' : $styl='nieparzysty';
echo '<tr class="'.$styl.'">'; echo '<td class="dane_d" style="border-left:1px #999999 solid;">'.$oClient->getCompany().'</td>'; echo '<td class="dane_d">'.$oClient->getNip().'</td>'; echo '<td class="dane_d">'.$oClient->getEmail().'</td>'; echo '<td class="dane_d">'.$oClient->getStreet().'</td>'; echo '<td class="dane_d">'.$oClient->getZipCode().' '.$oClient->getCity().'</td>'; echo '<td class="dane_d">'; echo '<a href="?part=reports&action=screports&clientid='.$oClient->getId().'">Pokaż raporty</a>'; echo '<a href="?part=reports&action=add&clientid='.$oClient->getId().'">Dodaj raport</a>'; '</td>';
}
?>