Welcome Guest, Not a member yet? Register   Sign In
readfile and insert to db help
#14

[eluser]flaky[/eluser]
try this

Code:
<?php

class Stock_model extends Model{

    public function __construct(){
        parent::__construct();
    }
    
    function putData($txt)
    {
        $handle = file_get_contents($txt);
        $var_array = explode(";",$handle);
        $a = array_chunk($var_array,4);
        
            for($i=0;$i<sizeof($a);$i++)
            {
                if(isset($a[$i][1]))
                    $a[$i][1] = preg_replace("/\s\%/","%",$a[$i][1]);
                
                if(isset($a[$i][0]))
                    $data['compcode'] = $a[$i][0];
                
                if(isset($a[$i][1]))
                    $data['pricepercent'] = $a[$i][1];
                    
                if(isset($a[$i][2]))
                    $data['compname'] = $a[$i][2];
                    
                if(isset($a[$i][3]))
                    $data['volume'] = $a[$i][3];
                
                //print_r($data);
                //$this->db->insert('stocks',$data);
            }

        return $this->db->affected_rows();
    }

}


Messages In This Thread
readfile and insert to db help - by El Forum - 01-19-2010, 05:16 AM
readfile and insert to db help - by El Forum - 01-19-2010, 05:19 AM
readfile and insert to db help - by El Forum - 01-19-2010, 05:19 AM
readfile and insert to db help - by El Forum - 01-19-2010, 05:21 AM
readfile and insert to db help - by El Forum - 01-19-2010, 05:23 AM
readfile and insert to db help - by El Forum - 01-19-2010, 05:28 AM
readfile and insert to db help - by El Forum - 01-19-2010, 05:35 AM
readfile and insert to db help - by El Forum - 01-19-2010, 05:37 AM
readfile and insert to db help - by El Forum - 01-19-2010, 05:40 AM
readfile and insert to db help - by El Forum - 01-19-2010, 05:42 AM
readfile and insert to db help - by El Forum - 01-19-2010, 05:48 AM
readfile and insert to db help - by El Forum - 01-19-2010, 05:51 AM
readfile and insert to db help - by El Forum - 01-19-2010, 06:22 AM
readfile and insert to db help - by El Forum - 01-19-2010, 06:52 AM
readfile and insert to db help - by El Forum - 01-19-2010, 07:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB