0

Hello Every body I have an SQL Query to DB

function darkSiteContent($delta){
     switch ($delta) {
     //SQL Query to find the title , nid of the node and its body
     case 'popup_dark_screen':
      $result = db_query("
        SELECT n.title , n.nid , b.body_value
        FROM {dot_node} as n , {dot_field_revision_body} as b , {dot_node_type} as t
        WHERE t.type = 'dark_sit' AND n.type = t.type and b.bundle = t.type 
        order by n.title desc LIMIT 1
        ");
        $items = array();
        foreach ($result as $row) {
        print_r($row);
        $items[] = l(t($row->title, 'node/' . $row->nid )).'
'.$row->body_value; } return array('#markup' => theme('item_list', array('items' => $items))); break; } }

But it show this error

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'APIG01JO2012039.dot_dot_node' doesn't exist: SELECT n.title , n.nid , b.body_value FROM {dot_node} as n , {dot_field_revision_body} as b , {dot_node_type} as t WHERE t.type = 'dark_sit' AND n.type = t.type and b.bundle = t.type order by n.title desc LIMIT 1 ; Array ( ) in darkSiteContent() (line 71 of C:\AppServ\www\APIG01JO2012039\sites\all\modules\darksite\darksite.module).

I am sure of my table name but it still show this error

  • try giving the table name as just node instead of dot_node – Mohammed Shameem Jan 24 '13 at 7:33
3

When using database with in {} you don't need to add the prefix of the table it is automatically added by drupal in your case since you have placed it between {} it is adding another dot_ so the table name is becoming dot_dot_node instead of dot_node.

Note the relevant section from Drupal Database API documentation

Prefixing

In static queries, all table names must be wrapped in {}. That flags them so that the database system can attach a prefix string to them if appropriate. Prefixing allows for running multiple sites from the same database or, in limited cases, for sharing selected tables between sites.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.