Submitted by
Dmitro
on
To remove views unsaved changes, sometimes can be usefull when after views change you cannot access edit page.
drush eval "\Drupal::keyValueExpirable('tempstore.shared.views')->delete('VIEW_NAME');"
To get query from the view:
$query = $view->getQuery();
$query_string = $query->query()->__toString();
dpm($query_string);
To get arguments:
$arguments = $queryNew->query()->getArguments();
To get query with arguments and remove brackets:
$query_string = str_replace("{",'', $query_string);
$query_string = str_replace("}",'', $query_string);
foreach ($arguments as $key => $item){
if (is_array($item)) {
$item = implode(',', $item);
}
$query_string = str_replace($key, $item, $query_string); }
dsm($query_string);
dsm($queryNew->query()->execute()->fetchAll());
Another:
$query = $view->getQuery();
$query_string = $query->query()->__toString();
$arguments = $query->query()->getArguments();
$query_string = str_replace("{",'', $query_string);
$query_string = str_replace("}",'', $query_string);
$query_string = str_replace('"','`', $query_string);
foreach (array_reverse($arguments) as $key => $item) {
if (is_array($item)) {
$item = implode(',', $item);
}
$query_string = str_replace($key, $item, $query_string);
}