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

  • Home
  • SEARCH
  • 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 6819157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:16:21+00:00 2026-05-26T21:16:21+00:00

I have created a temporary table using cakephp $this->Model->query() and inserted some records using

  • 0

I have created a temporary table using cakephp $this->Model->query() and inserted some records using the same $this->Model->query(). I want to paginate the temporary table. I have loaded the temporary model as follows.

App::import('Model', $tmpModel);
$this->loadModel($tmpModel);

Ref Url:
Create temporary table in CakePHP and load it as a Model

Unfortunately the pagination did not happen and i got the following error.

Database table “table name” for model “model name” was not found. Though the table name and model name were written as per the cakephp convention.

What might be the possible solution for it.

  • 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-26T21:16:22+00:00Added an answer on May 26, 2026 at 9:16 pm

    I’m almost certain that you won’t be able to do this using temporary tables. This is because’s Cake’s underlying schema caching uses MySql’s ‘SHOW TABLES‘ which doesn’t return temporary tables – hence the reason you’ll always get the “Database table “table name” for model “model name” was not found”

    My suggestion therefore would be to create a standard table and then drop it once you’re finished. Here is a example that could be call from a ‘Users‘ controller:

    // Define temporary model
    $tempModel = 'TempUser';
    
    // Create table
    $this->User->query("CREATE TABLE IF NOT EXISTS `". Inflector::tableize($tempModel)  ."` (
      `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
      `name` varchar(255) NOT NULL DEFAULT '',
      `email` varchar(255) NOT NULL DEFAULT '',
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
    
    // load the model
    $this->loadModel($tempModel);
    
    /**
     * Prevent caching of database schema and then get
     * the latest schema that includes our new table
     */
    $this->$tempModel->cacheSources = false;
    $this->$tempModel->schema();
    
    // Save
    $this->$tempModel->save(array(
      $tempModel => array(
        'name' => 'Testing',
        'email' => 'joe.bloggs@google.co.uk'
      )
    ));
    
    // Paginate
    $data = $this->paginate($tempModel);
    
    // Drop Table
    $this->User->query("DROP TABLE `". Inflector::tableize($tempModel)  ."`");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have optimized a complex Oracle statement using temporary table like this : original
I'm using SQL Server 2005. I have a temporary sorted table ( Table_A )
I have a string like following: CREATE GLOBAL TEMPORARY TABLE some_temp_table_name or CREATE GLOBAL
I have a sample file like the following: CREATE GLOBAL TEMPORARY TABLE tt_temp_user_11 (
Using the .net framework you have the option to create temporary files with Path.GetTempFileName();
I have created a custom dialog for Visual Studio Setup Project using the steps
I have created a C# class file by using a XSD-file as an input.
I have a stored procedure inside which I create a temporary table that typically
I have a temporary table with about 1 million entries. The temporary table stores
I have a query that creates several temporary tables and then inserts data into

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.