function example_dbtng in Coder 7
Same name and namespace in other branches
- 7.2 coder_upgrade/tests/old/samples/example.module \example_dbtng()
File
- coder_upgrade/
tests/ old/ samples/ example.module, line 377
Code
function example_dbtng() {
// db_query() -- Change the next line but leave this alone
// Insert query.
db_query("INSERT INTO {mytable} (intvar, stringvar, floatvar) VALUES (%d, '%s', %f)", 5, 'hello world', 3.14);
$sql = "INSERT INTO {mytable} (intvar, stringvar, floatvar) VALUES (%d, '%s', %f)";
db_query($sql, 5, 'hello world', 3.14);
$values = array(
5,
'hello world',
3.14,
);
db_query($sql, $values);
$id = db_last_insert_id();
// Update query.
db_query("UPDATE {node} SET title='%s', status=%d WHERE uid=%d", 'hello world', 1, 5);
// Delete query.
db_query("DELETE FROM {node} WHERE uid=%d AND created < %d", 5, time() - 3600);
}