What happening in these 2 php files?! help

Coding Critique is the place to post source code for peer review by other members of DevNetwork. Any kind of code can be posted. Code posted does not have to be limited to PHP. All members are invited to contribute constructive criticism with the goal of improving the code. Posted code should include some background information about it and what areas you specifically would like help with.

Popular code excerpts may be moved to "Code Snippets" by the moderators.

Moderator: General Moderators

Post Reply
k1llswltch
Forum Newbie
Posts: 1
Joined: Wed Feb 02, 2011 1:17 pm

What happening in these 2 php files?! help

Post 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();


?>
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

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

Post 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.
Post Reply