This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$query = db_select('node', 'n'); | |
$nids = $query | |
->fields('n') | |
->condition('type', 'fitspirator') | |
->execute() | |
->fetchCol(); | |
$nodes = node_load_multiple($nids); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$field = 'VOCABULARY_MACHINE_NAME'; | |
// Search for unused taxonomy terms. | |
$query = db_query('SELECT DISTINCT field_' . $field . '_tid FROM field_data_field_' . $field . ' WHERE field_' . $field . '_tid NOT IN (SELECT tid FROM taxonomy_term_data)'); | |
$results = $query->fetchCol(); | |
// Output results with devel. | |
dpm($results); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Create user for every fitspirator node without any entity reference. | |
*/ | |
$query = db_select('node', 'n'); | |
$nids = $query | |
->fields('n', array('nid')) | |
->condition('type', 'fitspirator') | |
->execute() | |
->fetchCol(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$args = array(':type' => 'fitspirator'); | |
$node = "UPDATE node AS n SET n.comment = 2 WHERE n.type = :type"; | |
db_query($node, $args); | |
$node_revision = "UPDATE node_revision AS nr JOIN node AS n ON nr.nid = n.nid SET nr.comment = 2 WHERE n.type = :type"; | |
db_query($node_revision, $args); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$results = db_select('node', 'n') | |
->fields('n', array('nid')) | |
->condition('type', TYPE) | |
->execute(); | |
foreach ($results as $result) { | |
$nids[] = $result->nid; | |
} | |
if (!empty($nids)) { | |
node_delete_multiple($nids); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* For removing inline CSS from body fields in Drupal. | |
* | |
* -Install devel module. | |
* -Navigate to devel/php. | |
* -Paste the following code and execute. | |
*/ | |
$results = db_select('field_data_body', 'f') | |
->fields('f', array('entity_id', 'body_value')) |