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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:45:52+00:00 2026-06-14T23:45:52+00:00

i am running a cronjob every 5mins on a file that is pulling in

  • 0

i am running a cronjob every 5mins on a file that is pulling in a xml feed, at the moment it is just adding that feed to the database, so i may get below.

title, this is a new title
title, this is another title

but the problem i have got is when the cron runs again i get below

title, this is a new title
title, this is another title
title, this is a new title
title, this is another title

and when it runs again

title, this is a new title
title, this is another title
title, this is a new title
title, this is another title
title, this is a new title
title, this is another title

And so on…..

i only want it to insert a records if their is not one already in the database with the same title so my cron job will keep running and when it notices a different title THEN it inserts it into the db.

I have tried lots of separate option such a not_like etc.

Can someone tell me the best way to do this???

Thankyou 😉

I managed to do it with the following but definitely not the best way todo it

    function addResults($data){

   $this->db->select('title');
       $this->db->from('articles');
       $this->db->where('title = ' . "'" . $data['title'] . "'");
       //$this->db->limit(1);
       $query=$this->db->get();
       echo $query->num_rows();
       if($query->num_rows()){

   }else{
        echo 'New Record ' . $data['title'];
        $this->db->set('date', 'NOW()', FALSE); 
            $this->db->insert('articles', $data);
        }

    }
  • 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-06-14T23:45:53+00:00Added an answer on June 14, 2026 at 11:45 pm

    I know I’m a little late for the party but here is a slightly better way to do it:

    function addResults($data)
    {
        $result = $this->db->get_where('articles', array('title ' => $data['title']));
        $inDatabase = (bool)$result->num_rows();
    
        if (!$inDatabase)
        {
            echo 'New Record ' . $data['title'];
            $this->db->set('date', 'NOW()', FALSE); 
            $this->db->insert('articles', $data);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running a cronjob that calls a php script. I get failed to open
I'm trying to create a cronjob to back up my database every night before
I have a simple cronjob running every day at 18:35: 05 18 * *
I have 1 cronjob that runs every 60 minutes but for some reason, recently,
I just recently asked this question: https://stackoverflow.com/questions/6359367/running-a-bash-program-every-day-at-the-same-time The solution of using crontab -e to
I created a cronjob which call a php-script every 5mins. This PHP script needs
I have one domain that is running a cron job every 15mins. I starts
I have a servlet running on GAE and I have a cron job that
Running my script through Devel::NYTProf showed that the following portion of code took up
Running SQL Server 2008 (not R2). I have a few reports that have URLs

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.