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

[eluser]sasori[/eluser]
ok sir this is my stock_model

Code:
class Stock_model extends Model
{

    function Stock_model()
    {
      parent::Model();
    }

    function getStocks()
    {
      $data = array();
      $data[] = $this->db->get('stocks');
      return $data;
    }

    function putData($txt)
    {
      $handle = file_get_contents($txt);
      $var_array_parent = explode("\n",$handle);
      foreach($var_array_parent as $value)
      {
        $var_array = explode(";",$value);
        $a = array_chunk($var_array,4);
        for($i=0;$i<sizeof($a);$i++)
        {
          $a[$i][1] = preg_replace("/\s\%/","%",$a[$i][1]);

          $data = array(
                        'compcode' => $a[$i][0],
                        'pricepercent' => $a[$i][1],
                        'compname' => $a[$i][2],
                        'volume' => $a[$i][3]);

          $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