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 33That 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
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:Problem solved. Documentation for EE2 should probably be updated with this though.$this->EE->db->insert('exp_extensions',
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"
)
)
);
}
// ENDPacket Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.