Skip to content

Instantly share code, notes, and snippets.

@algotrader-dotcom
Created June 11, 2018 17:21
Show Gist options
  • Select an option

  • Save algotrader-dotcom/ba647942e24c58f1b2e059ce0219fb22 to your computer and use it in GitHub Desktop.

Select an option

Save algotrader-dotcom/ba647942e24c58f1b2e059ce0219fb22 to your computer and use it in GitHub Desktop.
Drupal 8 : Static db query
<?php /* Main */
use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;
$autoloader = require_once 'autoload.php';
$kernel = new DrupalKernel('prod', $autoloader);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
use Drupal\node\Entity\Node;
use Drupal\file\Entity\File;
use Drupal\taxonomy\Entity\Term;
$connection = \Drupal::database();
$query = $connection->query("select distinct title,changed from node_field_data order by changed limit 50");
$results = $query->fetchAll();
foreach ($results as $result) {
print_r($result);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment