database

Drupal 7 Cheat Sheet: The Database

This is a quick post while it's fresh in my head, regarding porting your contributed modules to the Drupal 7 API. This post specifically focusses on database manipulation and provides the like-for-like changes. If anything here is wrong, or could be done better, please let me know!

First up, individual results:

<?php
/*
* Remember this?
*/
$value = db_result(db_query("SELECT some_field FROM {some_table}"));

/*
* Forget it! It now looks like this:
*/
$value = db_query("SELECT some_field FROM {some_table}")->fetchField();
?>

Duplicate Keys: Repairing The Sequences Table

So normal service resumes. Well, just about, at any rate.

Just a quick entry today about the 'sequences' table in the Drupal database. If you've ever seen this sort of error and not known what to do, then you'll find this post extremely useful:

Duplicate entry '4' for key

Syndicate content