Commit d737d8f5 authored by shajiaiming's avatar shajiaiming

fix

parent dd342d1d
<?php
namespace api\controllers;
use Yii;
use api\base\BaseController;
use common\models\psources\CoinClientParams;
class ClientParamsController extends BaseController
{
public function actionIndex()
{
$code = 0;
$msg = 'success';
$data = CoinClientParams::find()->asArray()->all();
if(empty($data)){
$msg = '数据不存在';
$data = null;
$code = -1;
goto doEnd;
}
foreach ($data as &$val) {
if(strpos( $val['url'], ',') !== false) {
$val['url'] = explode(',', $val['url']);
}
}
doEnd :
return ['code' => $code, 'data' => $data, 'msg' => $msg];
}
}
\ No newline at end of file
<?php
namespace common\models\psources;
use Yii;
use common\core\BaseActiveRecord;
class CoinClientParams extends BaseActiveRecord
{
public static function getDb()
{
return Yii::$app->get('p_sources');
}
public static function tableName()
{
return '{{%coin_client_params}}';
}
//定义场景
const SCENARIOS_CREATE = 'create';
const SCENARIOS_UPDATE = 'update';
public function rules() {
return [
[['type','url'], 'required'],
];
}
public function scenarios() {
$scenarios = [
self:: SCENARIOS_CREATE => ['type','url'],
];
return array_merge( parent:: scenarios(), $scenarios);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment