You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
skycaiji/plugin/release/diy/Demo.php

41 lines
1.4 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
namespace plugin\release\diy;
/*自定义插件:类名首字母必须大写*/
class Demo extends BaseDiy{
/*数据库连接信息*/
public $connection = array(
'db_type' => 'mysql', //类型
'db_host' => 'localhost', //服务器
'db_name' => 'test', //库名称
'db_user' => 'root', //用户名
'db_pwd' => '', //密码
'db_port' => 3306, //端口
'db_prefix' => '', //表前缀
'db_charset' => 'utf8mb4', //编码
);
/**
* 导入数据
* @param string $url 采集的页面网址
* @param array $fields 采集到的字段数据列表
*/
public function runImport($url,$fields){
/*
* -----这里开始写代码-----
* 数据库操作:$this->db() 可参考thinkphp5的数据库操作
* 获取字段值必须使用 $this->get_field_val($field);方法(可处理图片本地化等),否则使用$field['value']调用字段原始值
*/
/*
* 必须以数组形式返回:
* id必填表示入库返回的自增id或状态
* target可选记录入库的数据位置发布的网址等
* desc可选记录入库的数据位置附加信息
* error可选记录入库失败的错误信息
* 入库的信息可在“已采集数据”中查看
*/
return array('id'=>0,'target'=>'','desc'=>'','error'=>'');
}
}
?>