Monday, February 24, 2014

Delete operation in Drupal 7

The following function is used to delete file and file usage in Drupal 7.
file_data($file);

The following db function is used to delete a record from a table in Drupal 7.
db_delete('table')->condition('field', $value->execute();

The following drupal function is used to delete a node in Drupal 7.
node_delete($nid);
Multiple node delete: node_multiple_delete(array($nid1, $nid2));

The following drupal function is used to delete a user in Drupal 7.
user_delete($uid);
Multiple user delete: user_multiple_delete(array($uid1, $uid2));

The following drupal function is used to delete a content type in Drupal 7.
node_type_delete($type);

Friday, February 21, 2014

Use file_prepare_directory() instead of file_check_directory()

In Drupal 7, use file_prepare_directory() instead of file_check_directory() from Drupal 6.

Drupal 6 file_directory_path not exists in Drupal 7

Drupal 6 file_directory_path not exists in Drupal 7. Use variable_get('file_public_path', conf_path() . '/files'); instead of file_directory_path();

The following function is return file directory relative path:  drupal_realpath('public://')

Thursday, February 13, 2014

Image not imported in Drupal 7 migration from Druapl 6

In node_export drupal module having issue to import images/files in Drupal 7

Fixed:
In Drupal 7, we have to use file_create_url() instead of url() in node_export.module line no 1052 - Refer - https://drupal.org/node/1264256

Find table column in MySQL

The following query is used to show all columns in each table in a database

SELECT * FROM information_schema.columns
WHERE table_schema = 'db_name'
ORDER BY table_name,ordinal_position