Creini
asked on
Objects and session
Hi, I'm trying to create an object called Folder and in it I want to keep x Paper objects. Is it possible to keep these objects in a session? So I don't have to load the entire folder everytime I want to load view a page in the folder. I just want to load (from the db) when I'm getting a new Folder
My objects look like this:
Folder:
<?php
class Folder
{
var $papers; // Paper in the folder
var $myIndex;
var $myName; // Category of the folder e.g Examples
var $myDescription; //Describe whats in the folder
var $myImage; //Standard image of folder
function Folder($name,$description, $image) {
$this->myIndex = 0;
$this->myName = $name;
$this->myDescription = $description;
$this->myImage = $image;
}
// Add a paper to the folder
function addPaper ($paper) {
$this->papers[$this->myInd ex] = $paper;
$this->myIndex++;
}
function getPaper ($index) {
return $this->papers[$index];
}
function getName() {
return $this->myName;
}
function getDescription() {
return $this->myDescription;
}
function getImage() {
return $this->myImage;
}
function getSize() {
return $this->myIndex;
}
}
?>
Paper:
<?php
class Paper
{
var $myId; // Id number in the database
var $myFolder; // Name of the folder it belongs to (e.g. News, Info)
var $myTitle; // The title of the paper
var $myContent; // The actual "article"
var $myImage; // Name of the image associated with the paper
function Paper($id,$folder,$title,$ content,$i mage) {
$this->myId = $id;
$this->myFolder = $folder;
$this->myTitle = $title;
$this->myContent= $content;
$this->myImage = $image;
}
function getId() {
return $this->myId;
}
function getFolder() {
return $this->myFolder;
}
function getTitle() {
return $this->myTitle;
}
function getContent() {
return $this->myContent;
}
function getImage() {
return $this->myImage;
}
}
?>
/Mattias
My objects look like this:
Folder:
<?php
class Folder
{
var $papers; // Paper in the folder
var $myIndex;
var $myName; // Category of the folder e.g Examples
var $myDescription; //Describe whats in the folder
var $myImage; //Standard image of folder
function Folder($name,$description,
$this->myIndex = 0;
$this->myName = $name;
$this->myDescription = $description;
$this->myImage = $image;
}
// Add a paper to the folder
function addPaper ($paper) {
$this->papers[$this->myInd
$this->myIndex++;
}
function getPaper ($index) {
return $this->papers[$index];
}
function getName() {
return $this->myName;
}
function getDescription() {
return $this->myDescription;
}
function getImage() {
return $this->myImage;
}
function getSize() {
return $this->myIndex;
}
}
?>
Paper:
<?php
class Paper
{
var $myId; // Id number in the database
var $myFolder; // Name of the folder it belongs to (e.g. News, Info)
var $myTitle; // The title of the paper
var $myContent; // The actual "article"
var $myImage; // Name of the image associated with the paper
function Paper($id,$folder,$title,$
$this->myId = $id;
$this->myFolder = $folder;
$this->myTitle = $title;
$this->myContent= $content;
$this->myImage = $image;
}
function getId() {
return $this->myId;
}
function getFolder() {
return $this->myFolder;
}
function getTitle() {
return $this->myTitle;
}
function getContent() {
return $this->myContent;
}
function getImage() {
return $this->myImage;
}
}
?>
/Mattias
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
include_once('classes.inc'
session_start();