Link to home
Start Free TrialLog in
Avatar of M-Geek
M-Geek

asked on

Translate drupal views export to MySQL Query...

Hi all,

This time I will probably ask more than I would normally do but I have a little emergency here.  My SQL developer is out sick and I have to finish something for a client.

I was trying to do a data (content) export from drupal 5 to import it into a drupal 6 installation but I'm having a hard time getting it done.  I Installed the Views Bonus pack module ( http://drupal.org/project/views_bonus ) which gives you a really nice CSV export but the problem is that the output is not in SQL format and therefore I wouldn't be able to import it directly into the D6 database directly.  Unfortunately my SQL querying coding is less than beginner level and I can't figure it out how to put this query together that I can run in PHPmyAdmin to get the data.

Could any of you Drupal or MySQL masters be able to translate this view export into a MySQL query for me?

I'll be forever grateful if you could!

Thanks in advance.


$view = new stdClass();
  $view->name = 'aaaa';
  $view->description = 'Data export';
  $view->access = array (
);
  $view->view_args_php = '';
  $view->page = TRUE;
  $view->page_title = '';
  $view->page_header = '';
  $view->page_header_format = '4';
  $view->page_footer = '';
  $view->page_footer_format = '4';
  $view->page_empty = '';
  $view->page_empty_format = '4';
  $view->page_type = 'views_csv';
  $view->url = '';
  $view->use_pager = FALSE;
  $view->nodes_per_page = '0';
  $view->sort = array (
    array (
      'tablename' => 'node',
      'field' => 'created',
      'sortorder' => 'DESC',
      'options' => 'normal',
    ),
  );
  $view->argument = array (
  );
  $view->field = array (
    array (
      'tablename' => 'node',
      'field' => 'nid',
      'label' => '',
    ),
    array (
      'tablename' => 'node',
      'field' => 'title',
      'label' => '',
      'handler' => 'views_handler_field_nodelink',
      'options' => 'link',
    ),
    array (
      'tablename' => 'node',
      'field' => 'body',
      'label' => '',
      'handler' => 'views_handler_field_body',
    ),
    array (
      'tablename' => 'node',
      'field' => 'body',
      'label' => '',
      'handler' => 'views_handler_field_teaser',
    ),
    array (
      'tablename' => 'node',
      'field' => 'created',
      'label' => '',
      'handler' => 'views_handler_field_date_large',
    ),
    array (
      'tablename' => 'node',
      'field' => 'type',
      'label' => '',
    ),
  );
  $view->filter = array (
    array (
      'tablename' => 'node',
      'field' => 'type',
      'operator' => 'OR',
      'options' => '',
      'value' => array (
  0 => 'blog',
),
    ),
    array (
      'tablename' => 'term_node_3',
      'field' => 'tid',
      'operator' => 'OR',
      'options' => '',
      'value' => array (
  0 => '2524',
),
    ),
    array (
      'tablename' => 'users_role_3',
      'field' => 'uid',
      'operator' => 'OR',
      'options' => '',
      'value' => array (
  0 => '28',
  1 => '170',
  2 => '195',
  3 => '196',
  4 => '292',
  5 => '2114',
  6 => '6203',
  7 => '7308',
  8 => '8264',
  9 => '8265',
  10 => '8266',
  11 => '8885',
  12 => '8987',
),
    ),
  );
  $view->exposed_filter = array (
  );
  $view->requires = array(node, term_node_3, users_role_3);
  $views[$view->name] = $view;

Open in new window

Avatar of profya
profya
Flag of Sudan image

No database schema available, I tried it from the above code and I hope it helps.
CREATE VIEW aaa AS
SELECT n.nid, n.title, n.body, n.created, n.type FROM node n INNER JOIN term_node_3 t ON n.nid=t.nid WHERE type='blog' OR tid='2524' OR n.uid IN (SELECT uid FROM term_node_3 WHERE '28', '170', '195, '196', '292', '2114', '6203', '7308', '8264', '8265', '8266', '8885''8987')

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of profya
profya
Flag of Sudan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of M-Geek
M-Geek

ASKER

This is one of those time where I wish I could give more points than the 500 limit!!!

You have no idea how helpful you've been!  Thank you so very much!