Welcome Guest, Not a member yet? Register   Sign In
Simple question about instances and stuff
#1

[eluser]Unknown[/eluser]
Hello!
Let's assume I have a Class that creates instances of users.
Certain type of users are allowed to post information through a form and I need to keep the instance of that user and a record of who poste what.

For example:

<code>
Class Post
{
var $user_id = 0;

function __construct($id)
{
$this->user_id = $id;
}

function create_post(){

does stuff ...

}

}


Class User
{

var $user_id = 0;
var $user_type = 0;

function __construct($id, $type)
{
$this->user_id=$id;
$user_type=$type;
}

function login()
{
...do things
$this->load->view(...some view containing the user profile layout);
}

function create_new_post(){

$post = new Post($this->user_id);
$post->create_post();

}

}


class Login extends CI_Controller{

code ... bla-bla

function validate_login(){
...id and type are given, validation is successful
$user= new User($type,$id);
$user->login();
}
}
</code>
now after the $user->login() i am sent to a view with a menu and stuff.
My question was ... can i somehow keep (or pass) the instance of the newly created user so that i can call the "create_new_post()" as an anchor? - base_url('/user/create_new_post')


I'm not sure if it's clear what I want ... but I hope you understand.

Thank you!




Theme © iAndrew 2016 - Forum software by © MyBB