I want to create a table with all the links in another one, but the proccess is too slow, I am doing this with CodeIgniter, and I want to know if there is a better way to do it.
This is my code:
foreach($results as $value) {
$ci->db->select('id');
$ci->db->where('url', $value->Url);
$link = $ci->db->get('links')->row();
if(@!$link) {
$ci->db->insert('links', array(
'title' => $value->Title,
'url' => $value->Url,
'description' => $value->Description,
'is_featured' => 0,
'published_date' => date('Y-m-d h:i:s')
));
$link_id = $ci->db->insert_id();
} else {
$link_id = $link->id;
}
$ci->db->where('link_id', $link_id);
$ci->db->where('term_id', $term_id);
$term_links = $ci->db->get('term_links')->row();
if(!$term_links) {
$ci->db->insert('term_links', array(
'link_id'=>$link_id,
'term_id'=>$term_id,
'order_link'=>$order,
'duplicates'=>0
));
} else {
$ci->db->where('id', $term_links->id);
$ci->db->update('term_links', array('duplicates'=>$term_links->duplicates+=1));
}
$order++;
}
Any idea? I use activerecords instead SQL.
Thank you in advance!
