Skip to content

Instantly share code, notes, and snippets.

@flowerains
Created December 6, 2013 07:24
Show Gist options
  • Save flowerains/7819888 to your computer and use it in GitHub Desktop.
Save flowerains/7819888 to your computer and use it in GitHub Desktop.
从服务器读数据录入到mysql数据库
<?php
public function getkm(){
if ($this->request->getGet()) {
ini_set('display_errors','On');
error_reporting(E_ALL);
$master = Factory::loadDB('master');
$kemiObj = Factory::loadModel('KemiCard',$master);
$filename = '/mnt/www/qiumi/Api/Controller/kemi.xls';
$filesize = filesize($filename);
$handle = fopen($filename,'rb');
$content = fread($handle,$filesize);
fclose($handle);
$one = preg_split('/\n/',$content);
$value = array();
foreach($one as $k=>$v){
$alex = array();
$alex = explode(',',$v);
foreach($alex as $j=>$p){
if($j == 8){
$value[] = trim($p);
}
}
}
foreach($value as $k=>$v){
$arr = array();
$arr = array(
'url'=>$v,
'uid'=>0,
'status'=>0,
);
$thiss = $kemiObj->add($arr);
}
print_r('ok');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment