This site has been archived. To learn more about our current products Ibexa Content, Ibexa Experience, Ibexa Commerce head over to the Ibexa Developer Portal

eZ Community » Forums » Developer » Bulkmail extension and db query

Bulkmail extension and db query

Bulkmail extension and db query

Monday 12 January 2004 12:28:47 pm - 13 replies

I have started making a bulkmail extension. But when I try to fetch something from the database in one of my php files I get this error message:
Fatal error: Call to a member function on a non-object in /opt/ezpublish/3.2.4/extension/bulkmail/modules/bulkmail/sendmail.php on line 29
Fatal error: eZ publish did not finish it's request

It seems $db is not an object. How do I get the $db object so I can query the dataase in my module? Here is the code:

include_once( "kernel/common/template.php" );

include_once( "lib/ezutils/classes/ezdebug.php" );
include_once( "lib/ezutils/classes/ezmodule.php" );
eZmodule::setGlobalPathList( array("kernel"blunk.gif Emoticon );
include_once( "lib/ezutils/classes/ezhttptool.php" );
include_once( "lib/ezutils/classes/ezini.php" );
//eZini::setIsCacheEnabled( false );
include_once( "lib/ezutils/classes/ezexecution.php" );

$db = null;
$db &= eZDB::instance();

$http =& eZHTTPTool::instance();
$tpl =& templateInit();

$from_email = $http->variable("from"blunk.gif Emoticon;
$from_name = $http->variable("from_name"blunk.gif Emoticon;
$to = $http->variable("togroup"blunk.gif Emoticon;
This is line 29:
$rows =& $db->arrayQuery( "SELECT * FROM ezsite_data" );

Any ideas??


Tuesday 13 January 2004 1:12:21 pm

I cant believe that nobody knows how to make a correct db-connection in a ezpublish extension. NOBODY? Please check my last message...

Thursday 15 January 2004 6:09:56 am

There is a problem there... I remember having the exact same one myself I just can't remember how I fixed it. Sorry. But this is how I do it (taken from working code, that I've long forgotten how it works) You can get the db params from site.ini if you need. I just know I figured out why you can't just get the db straight up but damnit I just can't remember.

$params = array('server' => 'localhost',
'user' => 'root',
'password' => 'thisismypassword',
'database' => 'ez',
'use_slave_server' => 'false',
'slave_server' => '',
'slave_user' => '',
'slave_password' => '',
'slave_database' => '',
'charset' => '',
'socket' => '',
'builtin_encoding' => '',
'connect_retries' => '',
'use_persistent_connection' => false);

$db = eZDb::instance('ezmysql', $params, true);

.... do all your stuff

Oh yeah and I have myself built a bulk mail extension to ez operating using workflows though, not its own module. Ie the user can choose to bulk mail an object to a list after they publish it. Which is quite usefull if I might say so... blunk.gif Emoticon


Thursday 15 January 2004 12:40:46 pm

Hi Willie,
It worked!! Thanks! By the way the workflow bulkmail you built is it public, do it contain any php coding and was is difficult?


Thursday 15 January 2004 1:53:17 pm

Wow, that sounds like an awesome event, Willie! I too would love to see this, or perhaps get some hints as to how it was built.


Eirik Johansen

Friday 16 January 2004 12:05:18 am

The bulk mail part was easy, it was getting the content | publish event to allow the fetching of a template to work that was the hard bit. It is built around this and since the fetch template stuff is very hacky I'm not sure if I'll release it - most people would probably find it mucks up their system.


Friday 16 January 2004 2:41:52 pm

Something similar will be posted by Hans and Tom soon: ad hoc distribution lists for use in post-publishing events. That is after tests proved it works with the ezmultiplexer workflow (it already works without).

It is taylored to what we need locally, but we also try to make it useful enough to cover a larger scope too.


Friday 16 January 2004 3:47:00 pm

Actually, Tom is preparing a little readme for the "bulkmail" event. Our tests of the event after an ezmultiplexer redirection have been succesful.

The event will use one or more attributes of a class and search for email addresses in that text (e.g. a class containing the ezauthor datatype).


Friday 16 January 2004 4:03:52 pm

The workflow event has been posted:

It's mostly suited to our needs, but it should work as a general solution as well.


Monday 26 January 2004 9:37:36 am

Hi Hans,

Thanks for making your mailinglist extension available to the public. Having just installed it, I have a few questions regarding this extension.

First of all, I'm confused about the parent node/current node setting. If I have understood it correctly (which I don't think I have), selecting "current node" will publish the current node as an email, and selecting "parent node" will publish the parent node of the current node as an email. However, why would one want to publish the parent node?

Also, I assumed that the extension fetched email address from a list of objects (like objects of the user class) but that doesn't seems to be the case. Are the recipients instead stored as part of the published object?

Thanks in advance for clearing things up !


Eirik Johansen

Monday 26 January 2004 9:49:07 am

I wanted do download, or at least check the link to Hans's article: but I get module not found. I believe this is happening after the new sitelayout of, could you please correct the link ez???


Monday 26 January 2004 10:01:01 am

Meanwhile, here's the correct link:


Eirik Johansen

Monday 26 January 2004 10:28:54 am

Thanks Eirik,
I already figured that I actually could navigate there myself blunk.gif Emoticon So I have checked it out, but thanks anyway for guidance.


Monday 26 January 2004 3:45:46 pm

Hi Eirik,

About the confusion on "this node" or "parent node": it only refers to the link that is sent out which can be a parent node or the node itself. The first (parent node) is useful if you want to "attach" a distribution list to a node as child. The latter (this node) is useful if the distribution list is part of the object you want to send out an email . For the rest you need to configure the attribute which contains the email adresses and which can be for example a list based on the author datatype or even a text field where you typed a series of email addresses.

Please note it works ouside the notification system since you can configure to send out emails on first publishing only or also when updates are done.



Modified on Monday 26 January 2004 3:46:05 pm by Paul Borgermans


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from