Multiuser PHP5 app with AJAX - what pattern?
Posted: Sat Jun 14, 2008 10:39 am
Hi!
I am writing a PHP5 app which is to server multiple user at one time. I want to use AJAX for the UI. I also need to use certain imap functions. I have class in which I save the imap_stream as the following:
This works great when I am trzing to call function from within the class. However when I call the functions from outside this function it does not work. Here is what I ment:
That returns and error that no valid imap resource is avaliable. So what I am supposed to do? I tried useing $_SESSION to store info on imap connections but session is not suitable for that.
I am writing a PHP5 app which is to server multiple user at one time. I want to use AJAX for the UI. I also need to use certain imap functions. I have class in which I save the imap_stream as the following:
Code: Select all
class A{
protected _imap_connection;
protected function connectToServer($host, ...){
/*
* functions to handle connection
*/
$this->_imap_connection = $conn; //conn is the var for imap_open;
}
protected function doSth(){
// sth which needs info on imap_connection eg: imap_fetchbody
}
}
Code: Select all
class B extends A{
public function __construct(){
$this->doSth();
}
}