Drupal 8 countQuery()

kenneth
$result = \Drupal::database()->select('node')
  ->condition('type', 'article')
  ->countQuery()
  ->execute()->fetchField();

 

Drupal 8 Delete all content by code

kenneth
// Define entity type to lookup.
$entity_type = 'node';

// Execute a query in order to retrieve an array of Article's ids.
$ids = \Drupal::entityQuery($entity_type)
  ->condition('type', 'article')
  ->execute();

/** @var \Drupal\node\NodeStorage $controller */
$controller = \Drupal::entityTypeManager()
  ->getStorage($entity_type);

/** @var \Drupal\node\Entity\Node[] $entities */
$entities = $controller->loadMultiple($ids);

// Deletes permanently saved entities.
$controller->delete($entities);

 

Git Add New Remote

kenneth
git remote add  [REMOTE_NAME] [REPOSITORY_URL]
git push -u github master

 

Drupal 7 Drush install

kenneth
drush site-install --db-url=mysql://[db_username]:[db_username_password]@[localhost]:[port]/[database_name]

 

Git Remove Branches

kenneth
# Delete from local
git branch –D branch-name

# Delete from remote
git push origin :branch-name

# Another way to delete from remote
git push origin --delete branch-name

 

Subscribe to