Dear Techies,
This class is used to setting a mysql data to setter methods. this class having 2 setter method. and here i wrote short and efficient code for setting the values to Array List.
and any one can easily understand the process of each lines.
Here is my code.
This class is used to setting a mysql data to setter methods. this class having 2 setter method. and here i wrote short and efficient code for setting the values to Array List.
and any one can easily understand the process of each lines.
Here is my code.
ConnectDB();
//sql query
$query = "select * from users";
//query execution
$result_set = mysql_query($query);
//record count
$record_count = mysql_num_rows($result_set);
if ($record_count > 0) {
//array list object
$user_bean_list = new ArrayList();
//looping record set
while ($record_set = mysql_fetch_object($result_set)) {
//user_Details_DTO object
$user_bean = new user_Details_DTO();
//setting a mysql database values
$user_bean->set_user_id($record_set->user_id);
$user_bean->set_user_name($record_set->name);
//passing DTO object to arraylist 'add' method
$user_bean_list->add($user_bean);
}
//returing objects
return $user_bean_list;
} else {
//return false, if no record found.
return 0;
}
}
}?>







0 comments:
Post a Comment