Viewed   129 times

here is the part if having error.

Fatal error: Using $this when not in object context in /pb_events.php on line 6

line 6 is: $jpp = $this->vars->data["jpp"];

function DoEvents($this) {

    global $_CONF, $_PAGE, $_TSM , $base;

    $jpp = $this->vars->data["jpp"];

    $cache["departments"] = $this->db->QFetchRowArray("SELECT * FROM {$this->tables[job_departments]}");
    $cache["locations"] = $this->db->QFetchRowArray("SELECT * FROM {$this->tables[job_location]}");
    $cache["names"] = $this->db->QFetchRowArray("SELECT * FROM {$this->tables[job_names]}");
    $cache["categories"] = $this->db->QFetchRowArray("SELECT * FROM {$this->tables[job_categories]}");

Thanks a lot! appreciate!



$this only makes sense in methods, not in functions

this is ok

class Foo {
     function bar() {

this is not

function some() {

// edit: didn't notice he passes "$this" as parameter

advice: simply replace "$this" with "$somethingElse"

Monday, October 10, 2022

$this will not be available in a static function. You'll probably want to re-create $app within the static function:

static function store($key, $value)
    $app = base_url('application') . '/cache/';
    $key = sha1($key);
    $value = serialize($value);
    file_put_contents( $app . $key.'.cache', $value);

I'm not quite sure what you're trying to do in the grand context of your application, but you may not even need a static method in the first place.

Wednesday, August 10, 2022

So, after more testing and what not, I find that it's not actually a bug in the MySQLi libraries or in my code.

The Solution? Give the database user the "Execute" permission for the database in MySQL. I wrote and tested the SQL statements and functions while I was logged in as root, not the actual user that the script was using.

Oh the joys of IT.

Monday, September 19, 2022

1°) After a while searching for a solution, I finally decided to purchase some modules, instead of using the Odoo Demo account.

So, I just changed the credentials for my new database, and also opened the 8069 port for that specific URL. And it worked :)

Code :

$url = '';  // Edited here. Opening the 8069 port was the last step to make it work :)
$db = 'thedatabasename';                // Edited here
$username = 'usernameofthataccount';    // Edited here
$password = 'passwordofthataccount';    // Edited here


$common = ripcord::client($url.'/xmlrpc/2/common');
$uid = $common->authenticate($db, $username, $password, array());


$models = ripcord::client("$url/xmlrpc/2/object");
$partners = $models->execute_kw(
            array('is_company', '=', true)

foreach ($partners as $partner) {
    echo 'partner=['.$partner.']<br/>';

Output :

array(193) { [0]=> int(568) [1]=> int(570) [2]=> int(293) [3]=> int(378) [4]=> int(526)}

2°) The start( ) method won't work with the specific URL though

So, I'm not sure that the start( ) method will work with something else than a Demo account.

Also, Odoo's support told me to not include the "/start" part of the URL in the script. But, with or without the "/start" part, it didn't work.

Code :

$info = ripcord::client('')->start(); // Even using the specific IP, this is ot working in my case

echo 'hello';

Output :

Fatal error: Uncaught Ripcord_TransportException: Could not access in /var/www/vhosts/ Stack trace: #0 /var/www/vhosts/ Ripcord_Transport_Stream->post('http://102.16.1...', '<?xml version="...') #1 /var/www/vhosts/ Ripcord_Client->__call('start', Array) #2 {main} thrown in /var/www/vhosts/ on line 488

My Conclusion is :

Odoo DEMO has NOT worked for me, even if I followed the instructions from here :

Odoo's documentation


1°) a/ We can get an IP Address (url is like "") when we install manually our odoo server onto a different host server of our choice.

1°) b/ But if the odoo server is installed onto Odoo's official website (url is like ""), we have no IP Address. And I managed to open the 8069 port by asking for it to the web host support of my website.

So, to make it simple, I edited "" to "", for the case 1°) b/ :

$url = '';
$db = 'thedatabasename';
Friday, November 11, 2022

In my index.php I'm loading maybe foobarfunc() like this:

 foobar::foobarfunc();  // Wrong, it is not static method

but can also be

$foobar = new foobar;  // correct

You can not invoke method this way because it is not static method.


You should instead use:


If however you have created a static method something like:

static $foo; // your top variable set as static

public static function foo() {
    return self::$foo;

then you can use this:

Thursday, November 10, 2022

Like the error says, you can't use $this outside of the class definition. To use $_db outside the class definition, first make it public instead of private:

public $_db

Then, use this code:

$authDb = new AuthDb();
$authDb->_db->prepare($query); // rest of code is the same


You have to understand what $this actually means. When used inside a class definition, $this is used to refer to an object of that class. So if you had a function foo inside AuthDB, and you needed to access $_db from within foo, you would use $this to tell PHP that you want the $_db from the same object that foo belongs to.

You might want to read this question: PHP: self vs $this

Sunday, October 9, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :