Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6982739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:19:42+00:00 2026-05-27T18:19:42+00:00

I’ve built an application to run on the client side (JavaScript & HTML) which

  • 0

I’ve built an application to run on the client side (JavaScript & HTML) which needs to access and updated data on a server. It has a schema which consists of 5 tables. I’ve defined exactly what they should look like in JSON. I want these to be available as a JSON service served from a Drupal module. I understand how to use drupal_json_output to provide the results. I just can’t find a simple way to ensure the database table is created for them and then to add and remove items from it. I’d like to maintain Drupal’s independence from the underlying database. I don’t need any search functionality, forms functionality etc. I just want to use Drupal’s Database Abstraction.

At the moment I’ve tried the following in my install file:

/**
 * Implements hook_schema
 */
function rcsarooms_schema(){
    $schema = array();
    $schema['rcsarooms'] = array(
        'description' => 'Stores the structured information about the rooms and staircases.',
        'fields' => array(
            'ID' => array(
                'type' => 'varchar',
                'length' => 10,
                'not null' => TRUE,
                'description' => 'Primary Key: used in the URLs to identify the entity.'
            ),'Name' => array(
                'type' => 'varchar',
                'length' => 200,
                'not null' => TRUE,
                'description' => 'The name used for links in the navigation menues.'
            ),'ParentID' => array(
                'type' => 'varchar',
                'length' => 10,
                'not null' => TRUE,
                'description' => 'The ID of the parent element or "Root" if this is a root element'
            ),'Type' => array(
                'type' => 'varchar',
                'length' => 15,
                'not null' => TRUE,
                'description' => 'page, staircase, house, room or special'
            ),'BathroomSharing' => array(
                'type' => 'int',
                'description' => 'The number of people the bathroom is shared with (0 for unknown)'
            ),'RentBand' => array(
                'type' => 'int',
                'description' => 'The ID of the rent band the room is in.'
            ),'Floor' => array(
                'type' => 'int',

            'description' => 'The floor number (0 is courtyard level).'
        )
    ),
    'primary key' => array('ID')
);

return $schema;         
}

And the following in my module file:

/**
 * Implements hook_menu
 */
function rcsarooms_menu(){
    $items['rcsarooms'] = array(
        'page callback' => 'rcsarooms_callback',
        'access callback' => TRUE,
        'type' => MENU_CALLBACK
    );
   return $items;
}
function rcsarooms_callback(){
    drupal_json_output(db_query("SELECT * FROM {rcsarooms}"));
    drupal_exit();
    return;
}

This gives the following error when I attempt to navigate to rcsarooms:
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘db.rcsarooms’ doesn’t exist: SELECT * FROM {rcsarooms}; Array ( ) in rcsarooms_callback()

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:19:43+00:00Added an answer on May 27, 2026 at 6:19 pm

    You’re probably looking for hook_schema() which Drupal will use to create your custom tables when you install your module. It goes in the mymodule.install file.

    The Schema API will tell you everything you need to know about data types etc.

    For adding/removing items from the database use the db_insert(), db_update() and db_merge() functions

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I am trying to understand how to use SyndicationItem to display feed which is
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.