Page 1 of 1

What happening in these 2 php files?! help

Posted: Wed Feb 02, 2011 1:22 pm
by k1llswltch
I need someone to help me figure out what happening in these 2 php files.

1) class1.php
<?php
class Account{
function Account(){
$this->date_join_chapter = null;
$this->email = null;
$this->salutation = null;
$this->last_name = null;
$this->first_name = null;
$this->home_address = null;
$this->home_address_2 = null;
$this->home_town = null;
$this->home_state = null;
$this->home_zip = null;
$this->home_phone = null;


}
}
?>


2)class2.php
<?php
include "class1.php";

class AccountManager{
function getMemberById($p
._sId){
$query="SELECT * FROM `accounts` WHERE member_id = '".$p_sId."' LIMIT 1";
$result = mysql_query($query);
$l_xAccount = new Account();
while ($row = mysql_fetch_assoc($result)){
$l_xAccount->email = $row['email'];
$l_xAccount->salutation = $row['salutation'];
$l_xAccount->last_name = $row['last_name'];
$l_xAccount->first_name = $row['first_name'];
$l_xAccount->home_address = $row['home_address'];
$l_xAccount->home_address_2 = $row['home_address_2'];
$l_xAccount->home_town = $row['home_town'];
$l_xAccount->home_state = $row['home_state'];
$l_xAccount->home_zip = $row['home_zip'];
$l_xAccount->home_phone = $row['home_phone'];

if(mysql_num_rows($result)==0){
return null;
}else{
return $l_xAccount;
}
}

}


$AccountManager = new AccountManager();


?>

Re: What happening in these 2 php files?! help

Posted: Wed Feb 02, 2011 2:12 pm
by Jonah Bron
The first file is a class containing data about an account. The second class queries a database for a row with the given ID, fetches the data from the row, puts the data into a new Account object, and returns it.