Login to download the latest version of Mint and your favorite Pepper, purchase additional licenses, or post in the Forum. Don't have an account? Create one!

In Partnership with Media Temple

Mint Forum

API Suggestion: More robust query() method

Brandon Kelly
Third-Party Pepper Developer
Posted on Oct 15, '07 at 03:52 am

Just finished the big 1.0 of my first Pepper, Countertop. It’s very simple — just grabs the number of rows from a specified database table.

Only problem is that if you specify a different database, it can’t use the query() method, and thus the query can’t get logged like other queries.

So I suggest query() gets an optional second parameter: an associative array that defines the parameters of an alternative mysql connection. See Countertop’s getHTML_CounterTotal() method to see how I’m doing it.

Other than that, talk about a nice little API! I’m impressed.

Shaun Inman
Mint/Pepper Developer
Posted on Oct 15, '07 at 10:02 am

Hmm, you should be able to use $this->query() regardless of the database you’re connected to. It should just use the current database connection. I created a similar custom Pepper to track sales on haveamint.com. It connects to a separate database and uses the query method of the Pepper class.

What Mint really needs is a way to easily switch between multiple databases. My Pepper (not sure about yours) will break any Pepper that come after it when “Stagger Pane Loading” isn’t enabled because it changes the database connection without changing it back.

Brandon Kelly
Third-Party Pepper Developer
Posted on Oct 15, '07 at 12:27 pm

What I did was create a new connection (by assigning the 4th parameter of mysql_connect() to true), so that I wouldn’t chance breaking anything else.

Now that I think about it, maybe a better way to go would be to allow an optional second parameter to query() that specifies the mysql connection, and just gets forwarded right on to the second parameter of mysql_query().

You must be logged in to reply. Login above or create an account