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 7169267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:57:10+00:00 2026-05-28T14:57:10+00:00

I have an application that used another php cms system, which I am now

  • 0

I have an application that used another php cms system, which I am now transferring to CakePHP 1.3. I’ve come to a point where I need to transfer all my old articles in tblnewsarticles to my new CakePHP table articles. The tables have different fields, but I have been able to map all the ones I need to my new table. I created the following temporary migrate function in my ArticlesController class to perform this operation for me, but cannot have the data to save into my table. Everything seems to be OK, including I have done tests with debug($data) and debug($articles) and it shows the data, but I cannot save anything. I cannot see anything wrong with this so any help is appreciated…

//TEMPORARY FUNCTION THAT WILL BE DELETED/DEACTIVATED AFTER MIGRATION
function migrate(){                
        // FOR TESTING PURPOSES I SET LIMIT=1, BUT I HAVE OVER 4000 ARTICLES TO TRANSFER
    $articles = $this->Article->query(
        "SELECT articleID,subcategoryID,article_title,article_html,article_date,image_extension FROM tblnewsarticles LIMIT 1;"
    );

    foreach($articles as $article){
        $data['Article']['id'] = $article['tblnewsarticles']['articleID'];
        $data['Article']['published'] = 1;
        $data['Article']['title'] = $article['tblnewsarticles']['article_title'];
        $data['Article']['body'] = $article['tblnewsarticles']['article_html'];
        $data['Article']['main_image'] = 'cat_'.$article['tblnewsarticles']['subcategoryID'].'/'.$article['tblnewsarticles']['articleID'].'.'.$article['tblnewsarticles']['image_extension'];
        $data['Article']['category_id'] = $article['tblnewsarticles']['subcategoryID'];
        $data['Article']['user_id'] = 2;
        $data['Article']['created'] = $article['tblnewsarticles']['article_date'];

        if (!empty($data)) {
             $this->Article->create();
             $this->Article->save($data);                       
             $this->Session->setFlash('Migration processed successfully');
        }else{                      
             $this->Session->setFlash('Unsuccessful');
        }
    }   
}

======== THIS IS WHAT I DID THAT WORKED FOR ME ================

function migrateArticle(){

$articles = $this->Article->query(
                    "SELECT articleID,subcategoryID,article_title,article_html,article_date,image_extension FROM tblnewscategories;"
    );

    foreach($articles as $article){

    $categoryID = $article['tblnewsarticles']['subcategoryID'];
    $articleID = $article['tblnewsarticles']['articleID'];
    $articleTitle = $article['tblnewsarticles']['article_title'];
    $articleSlug = str_replace(" ","-",strtolower($articleTitle));
    $articleBody = $article['tblnewsarticles']['article_html'];
    $articleImage = 'cat_'.$article['tblnewsarticles']['subcategoryID'].'/'.$article['tblnewsarticles']['articleID'].'.'.$article['tblnewsarticles']['image_extension'];
    $articleDate = $article['tblnewsarticles']['article_date'];

   $this->Article->query("INSERT INTO categories (id, published, title, slug, body, main_image, category_id, user_id, created) VALUES('$articleID', '1', '$articleTitle', '$articleSlug', '$articleBody', '$articleImage', '$categoryID', '2', '$articleDate');");   
    }   
}
  • 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-28T14:57:12+00:00Added an answer on May 28, 2026 at 2:57 pm

    Don’t try to load 4000 records all at once and then process them individually. It’s probably easier with a single database query that copies everything. Something like

    INSERT INTO articles
        (id, published, title, body,
         main_image,
         category_id, user_id, created)
        SELECT articleID, 1, article_title, article_html,
              CONCAT('cat_', subcategoryID, '/', articleID, '.', image_extension),
              subcategoryID, 2, article_date
        FROM tblnewsarticles;
    

    (untested, of course)

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

Sidebar

Related Questions

The problem: we have one application that has a portion which is used by
i have mysql that is used on production server for php webshop application. sometimes
I have an application that used Macro. In this macro I would like to
Say I have an application that used an ORM (I am thinking of nHibernate
I have an application that is used on several hundred computers across the company
I have an existing 32-bit ASP.NET application that used 32-bit unmanaged DLLs. If I
I have a small lightweight application that is used as part of a larger
I have an application that was originally written in Borland C++ and used a
We have a Struts 2 web application that's used by pretty much every employee
We have an in house winform application that is used by about 20 users

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.