Welcome Guest, Not a member yet? Register   Sign In
Update/insert in chunks?
#3

[eluser]codex[/eluser]
continue:

Code:
else
                    {
                        // insert
                        $insert = array('pFeedId'             => $r['pFeedId'],
                                        'pVendor'             => $r['pVendor'],
                                        'pId'                 => $r['pId'],
                                        'pUrl'                 => $r['pUrl'],
                                        'pTitle'             => $r['pTitle'],
                                        'pTitleUrlSafe'     => normalize_string($r['pTitle'], '-'),
                                        'pDescription'         => $r['pDescription'],
                                        'pDescription2'     => $r['pDescription2'],
                                        'pImgSmall'         => $r['pImgSmall'],
                                        'pImgLarge'         => $r['pImgLarge'],
                                        'pPrice'             => $r['pPrice'],
                                        'pPriceOld'         => $r['pPriceOld'],
                                        'pCategory'         => $r['pCategory'],
                                        'pCategoryPath'     => $r['pCategoryPath'],
                                        'pSubCategory'        => $r['pSubCategory'],
                                        'pSubCategoryPath'     => $r['pSubCategoryPath'],
                                        'pStock'             => $r['pStock'],
                                        'pPriceShipping'    => $r['pPriceShipping'],
                                        'pTimeToShip'         => $r['pTimeToShip'],
                                        'pEAN'                 => $r['pEAN']
                                        );
                    
                        $this->CI->db->insert('products', $insert);
                    }
                }
            }
            else
            {
                foreach($res as $r)
                {
                    // insert
                    $insert = array('pFeedId'             => $r['pFeedId'],
                                    'pVendor'             => $r['pVendor'],
                                    'pId'                 => $r['pId'],
                                    'pUrl'                 => $r['pUrl'],
                                    'pTitle'             => $r['pTitle'],
                                    'pTitleUrlSafe'     => normalize_string($r['pTitle'], '-'),
                                    'pDescription'         => $r['pDescription'],
                                    'pDescription2'     => $r['pDescription2'],
                                    'pImgSmall'         => $r['pImgSmall'],
                                    'pImgLarge'         => $r['pImgLarge'],
                                    'pPrice'             => $r['pPrice'],
                                    'pPriceOld'         => $r['pPriceOld'],
                                    'pCategory'         => $r['pCategory'],
                                    'pCategoryPath'     => $r['pCategoryPath'],
                                    'pSubCategory'        => $r['pSubCategory'],
                                    'pSubCategoryPath'     => $r['pSubCategoryPath'],
                                    'pStock'             => $r['pStock'],
                                    'pPriceShipping'    => $r['pPriceShipping'],
                                    'pTimeToShip'         => $r['pTimeToShip'],
                                    'pEAN'                 => $r['pEAN']
                                    );
                
                    $this->CI->db->insert('products', $insert);
                }
            }
            
            // Set imported products number
            $this->CI->db->set('num_products', count($arr));
            $this->CI->db->where('id', $feed_id);
            $this->CI->db->update('datafeeds');
            
            // Clean up temp
            $this->CI->db->query('TRUNCATE TABLE products_temp');
            
            return TRUE;
        }
        else
        {
            return FALSE;
        }
    }


Messages In This Thread
Update/insert in chunks? - by El Forum - 02-14-2009, 07:55 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 08:02 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 08:06 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 08:25 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 08:28 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 08:30 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 08:32 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 08:33 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 08:35 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 08:37 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 08:44 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 08:45 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 08:48 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 08:50 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 08:52 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 08:53 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 08:55 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 08:58 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 08:58 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 08:59 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 09:00 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 09:08 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 09:13 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 09:22 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 09:23 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 09:26 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 09:43 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 09:44 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 09:46 PM
Update/insert in chunks? - by El Forum - 02-14-2009, 11:10 PM



Theme © iAndrew 2016 - Forum software by © MyBB