February 19, 2008

Disabling Drupal Modules via your Database

Filed under: Drupal, MySQL — Soleer @ 6:41 pm

Due to the occasional small (or large) fluke, your entire Drupal website can become inaccessible because of a module.  This is how you solve the problem: disable the specific module by altering values in your Drupal database.

In our case, we’ll use phpMyAdmin, but you can use whatever utility you prefer for database manipulation.  So, here is what you do:

  1. Login to your Drupal Database
  2. Access the ’system’ table.  If you added a table prefix: <prefix>, the table will be listed as ‘<prefix>system’
  3. Browse the table entries, and find the entry for the target module
  4. Edit the table entry, and change the status from ‘1′ to ‘0′
  5. The module is now disabled!

Hopefully that did the trick, and you can now use your website.

December 27, 2007

Get the ID generated from the previous INSERT opereration

Filed under: MySQL, PHP — Soleer @ 4:43 pm

With the PHP function mysql_insert_id( ), you can obtain the previous index generated from an insert operation.

The need for this capability came about when we were generating a MySQL database for invoice storage.  Our database contains an INVOICE table for customer billing information, and an INV_ITEM table for individual items that are included in each order.

 The INVOICE table uses inv_id as an AUTO INCREMENT primary key, and the INV_ITEM uses inv_id as an index value, so the invoice items may be associated with the correct invoice.  All of this worked great, but we needed to send an email with order information, and an order number corresponding to the inv_id so we could access the order easily from the database if need be. 

The answer was to use the mysql_insert_id( ) function immeadiately after the insert statement, which returns the generated ID, which was inv_id in our case.  We then stored the returned ID to a string, and used it where necessary in the rest of our code.

$sql = “INSERT INTO invoices (”.$key_string.”) VALUES (”.$value_string.”)”;
$result = mysql_query($sql) ;
$invoice_id = mysql_insert_id();
if (!$result) {
      die(’Invalid query: ‘ . mysql_error());
}

The result of the previous code was that our values were inserted into the database as required, with the inv_id generated, and then stored into the $invoice_id variable for further use in the code.

Who we are

Explore our history and character.

If you've ever been on a blind-date, odds are great that you know how disastrous "jumping before looking" can be. Feel free to do some online stalking here before you contact Soleer.

What We Do

"Girls only want boyfriends who have great skills." -Napoleon Dynamite

While we aren't looking to be your boyfriend and might not have "nunchuku skills," we do offer a number of other services and solutions to assist your organization.

What We’ve Done

As we say in Texas, "This ain't our first rodeo." Take a look at a sampling of some of our masterpieces, from logo design and brochure creation to webpage design and online community development.