We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

FATAL ERROR on enabling extensions in EE2

Development and Programming

Brett DeWoody's avatar
Brett DeWoody
140 posts
15 years ago
Brett DeWoody's avatar Brett DeWoody

I’m trying to create an extension for EE2 and get a fatal error when I try to enable my new extension.

The error is:

Fatal error: Call to a member function insert_string() on a non-object in /path/to/expressionengine/third_party/[extension_name]/ext.[extension_name].php  on line 33

That line corresponds to the activate_extension function:

function activate_extension() {
            global $DB;
            
            $DB->query($DB->insert_string('exp_extensions',
                                          array(
                                                'extension_id' => '',
                                                'class'        => $this->class_name,
                                                'method'       => "add_libraries",
                                                'hook'         => "publish_form_headers",
                                                'settings'     => "",
                                                'priority'     => 10,
                                                'version'      => $this->version,
                                                'enabled'      => "y"
                                              )
                                         )
                      );
        }

Line 33 is the $DB->query($DB->insert_string(‘exp_extensions’… line.

Anyone had this happen?

Thanks in advance!

-Brett

       
Brett DeWoody's avatar
Brett DeWoody
140 posts
15 years ago
Brett DeWoody's avatar Brett DeWoody

Ah, apparently the EE2 version of this is:

$this->EE->db->insert('exp_extensions',

Problem solved. Documentation for EE2 should probably be updated with this though.

       
Manuel Payano's avatar
Manuel Payano
144 posts
15 years ago
Manuel Payano's avatar Manuel Payano

The documentation is good 😊 Maybe you where looking at the wrong one. http://expressionengine.com/public_beta/docs/ http://expressionengine.com/public_beta/docs/development/usage/database.html#inserting

Ah, apparently the EE2 version of this is:
$this->EE->db->insert('exp_extensions',
Problem solved. Documentation for EE2 should probably be updated with this though.
       
Brett DeWoody's avatar
Brett DeWoody
140 posts
15 years ago
Brett DeWoody's avatar Brett DeWoody

I was looking at the Extension Development docs (http://expressionengine.com/public_beta/docs/development/extensions.html) which gave an example as:

// --------------------------------
//  Activate Extension
// --------------------------------

function activate_extension()
{
    global $DB;
    
    $DB->query($DB->insert_string('exp_extensions',
                                  array(
                                        'extension_id' => '',
                                        'class'        => "Example_ext",
                                        'method'       => "rewrite_admin_home",
                                        'hook'         => "admin_home_page_start",
                                        'settings'     => "",
                                        'priority'     => 10,
                                        'version'      => $this->version,
                                        'enabled'      => "y"
                                      )
                                 )
              );
}
// END
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.