getPk(); }catch (\Exception $ex){ $this->create_table(); parent::__construct($data); } } /** * 获取url的数量 * @param array|string $urls */ public function getCountByUrl($urls){ if(is_array($urls)){ $urls=array_map('md5', $urls); return $this->where('urlMd5','in',$urls)->count(); }else{ return $this->where('urlMd5',md5($urls))->count(); } } /*获取标题的数量*/ public function getCountByTitle($title){ if(empty($title)){ return 0; } return $this->where('titleMd5',md5($title))->count(); } public function getUrlByUrl($urls){ if(!is_array($urls)){ $urls=array($urls); } $urls=array_map('md5', $urls); return $this->field('`id`,`url`')->where(array('urlMd5'=>array('in',$urls)))->column('url','id'); } /** * 创建表 * @return boolean */ public function create_table(){ $tname=$this->get_table_name(); $exists=db()->query("show tables like '{$tname}'"); if(empty($exists)){ $table=<<execute($table); } } } ?>