本文整理汇总了PHP中app\models\Country::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Country::find方法的具体用法?PHP Country::find怎么用?PHP Country::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Country
的用法示例。
在下文中一共展示了Country::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLicensePaymentDetails
/**
* @param array $input
* @param Affiliate $affiliate
*
* @return array
*/
private function getLicensePaymentDetails(array $input, Affiliate $affiliate)
{
$country = Country::find($input['country_id']);
$data = ['firstName' => $input['first_name'], 'lastName' => $input['last_name'], 'email' => $input['email'], 'number' => $input['card_number'], 'expiryMonth' => $input['expiration_month'], 'expiryYear' => $input['expiration_year'], 'cvv' => $input['cvv'], 'billingAddress1' => $input['address1'], 'billingAddress2' => $input['address2'], 'billingCity' => $input['city'], 'billingState' => $input['state'], 'billingPostcode' => $input['postal_code'], 'billingCountry' => $country->iso_3166_2, 'shippingAddress1' => $input['address1'], 'shippingAddress2' => $input['address2'], 'shippingCity' => $input['city'], 'shippingState' => $input['state'], 'shippingPostcode' => $input['postal_code'], 'shippingCountry' => $country->iso_3166_2];
$card = new CreditCard($data);
return ['amount' => $affiliate->price, 'card' => $card, 'currency' => 'USD', 'returnUrl' => URL::to('license_complete'), 'cancelUrl' => URL::to('/')];
}
示例2: actionIndex
public function actionIndex()
{
$query = Country::find();
$pagination = new Pagination(['defaultPageSize' => 5, 'totalCount' => $query->count()]);
$countries = $query->orderBy('name')->offset($pagination->offset)->limit($pagination->limit)->all();
return $this->render('index', ['countries' => $countries, 'pagination' => $pagination]);
}
示例3: actionTest
public function actionTest()
{
$result = Country::find()->orderBy('population DESC')->all();
//获取全部
//var_dump($result);exit();
return $this->render('test', ['result' => $result]);
}
示例4: getCountries
public function getCountries()
{
$ret = [];
foreach (Country::find()->all() as $cc) {
$ret[$cc->key] = $cc->id;
}
return $ret;
}
示例5: actionIndex
public function actionIndex()
{
$country = new Country();
echo PRE;
$query = Country::find();
$pagination = new Pagination(['defaultPageSize' => 5, 'totalCount' => $query->count()]);
$countries = $query->orderBy('name')->offset($pagination->offset)->limit($pagination->limit)->all();
}
示例6: actionIndex
public function actionIndex()
{
$query = Country::find();
//$query = Country::find()->andWhere(['code'=>'AU']);
//初始化分页
$pagination = new Pagination(['pageSize' => 2, 'totalCount' => $query->count()]);
$countries = $query->orderBy('name')->offset($pagination->offset)->limit($pagination->limit)->all();
return $this->render('index', ['countries' => $countries, 'pagination' => $pagination]);
}
示例7: convertInputForOmnipay
public function convertInputForOmnipay($input)
{
$data = ['firstName' => $input['first_name'], 'lastName' => $input['last_name'], 'number' => $input['card_number'], 'expiryMonth' => $input['expiration_month'], 'expiryYear' => $input['expiration_year'], 'cvv' => $input['cvv']];
if (isset($input['country_id'])) {
$country = Country::find($input['country_id']);
$data = array_merge($data, ['billingAddress1' => $input['address1'], 'billingAddress2' => $input['address2'], 'billingCity' => $input['city'], 'billingState' => $input['state'], 'billingPostcode' => $input['postal_code'], 'billingCountry' => $country->iso_3166_2, 'shippingAddress1' => $input['address1'], 'shippingAddress2' => $input['address2'], 'shippingCity' => $input['city'], 'shippingState' => $input['state'], 'shippingPostcode' => $input['postal_code'], 'shippingCountry' => $country->iso_3166_2]);
}
return $data;
}
示例8: actionCountry
public function actionCountry()
{
$countries = Country::find()->orderBy('name desc')->all();
echo \yii\helpers\Json::encode($countries);
$countryUs = Country::findOne('US');
echo '<br />' . \yii\helpers\Json::encode($countryUs);
$countryUs->name = 'U.S.A.';
echo $countryUs->save() ? ' OK' : ' False';
}
示例9: getState
public function getState(Request $req)
{
$country = Country::find($req->id);
$state = state::where('country_code', $country->code)->get();
$html = '<option value="" selected>Choose Option</option>';
foreach ($state as $states) {
$html .= '<option value="' . $states->id . '">' . $states->name . '</option>';
}
echo $html;
}
示例10: getAttack
public function getAttack($playerHash, $countryIdFrom, $countryIdTo)
{
$from = Country::find($countryIdFrom);
/** @var $from Country */
$to = Country::find($countryIdTo);
$player = Player::getByHash($playerHash);
if ($from->isOwnedBy($player)) {
Action::attack($from, $to);
}
}
示例11: sender
public static function sender()
{
//todo: move to database
switch (Auth::user()->user_id) {
default:
case 4916903:
return new self(['first_name' => 'osu!store', 'last_name' => '', 'street' => 'Room 304, Build 700 Nishijin 7-7-1', 'city' => 'Sawara', 'state' => 'Fukuoka', 'zip' => '814-0002', 'country' => Country::find('JP'), 'phone' => '+819064201305']);
case 2:
return new self(['first_name' => 'osu!store', 'last_name' => '', 'street' => 'Nishi-Ooi 4-21-3 Birdie House A', 'city' => 'Shinagawa', 'state' => 'Tokyo', 'zip' => '140-0015', 'country' => Country::find('JP'), 'phone' => '+818013811430']);
}
}
示例12: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Country::find();
$dataProvider = new ActiveDataProvider(['query' => $query]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere(['population' => $this->population]);
$query->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'name', $this->name]);
return $dataProvider;
}
示例13: actionUpdate
/**
* Updates an existing Address model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
$countries = ArrayHelper::map(Country::find()->all(), 'country_id', 'country');
$cities = ArrayHelper::map(City::find()->all(), 'city_id', 'city');
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->address_id]);
} else {
return $this->render('update', ['model' => $model, 'countries' => $countries, 'cities' => $cities]);
}
}
示例14: search
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Country::find();
$dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSizeLimit' => [10, 100]], 'sort' => ['defaultOrder' => ['name' => SORT_ASC]]]);
$params = $this->processParams($params);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id]);
$query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'code', $this->code]);
return $dataProvider;
}
示例15: actionIndex
/**
* Lists all CountryData models.
* @return mixed
*/
public function actionIndex()
{
$model = Country::find()->all();
$file = Yii::$app->basePath . '/data/BP-各国能源具体数据-20151206.xlsx';
$PHPExcel = \PHPExcel_IOFactory::load($file);
$sheet = $PHPExcel->getSheet(5);
// 读取第一個工作表(编号从 0 开始)
$highestRow = $sheet->getHighestRow();
// 取得总行数
$highestColumm = $sheet->getHighestColumn();
// 取得总列数
// $years = 2014-1965+1;
// for($row = 4; $row <= $highestRow; $row++){
// $org = array();
// $country = null;
// $data_key = null;
// $data_value = null;
// $flag = true;
// // $row = 5;
// for ($column = 0; $column <= $years; $column++) {
// $column_name = \PHPExcel_Cell::stringFromColumnIndex($column);
// $val = (string)$sheet->getCell($column_name.$row)->getValue();
// if($column == 0){
// if($val == "US"){
// $val = "United States";
// }
// if($val == "Trinidad & Tobago"){
// $val = "Trinidad and Tobago";
// }
// $country_model = Country::find()->where([
// 'name_english' => $val,
// ])->one();
// if(!isset($country_model->id)){
// $country = null;
// continue;
// }else{
// $country = $country_model->id;
// }
// }
// if($column >=1 && trim($val)!="" && $country){
// $model = new CountryData();
// $model->country_id = $country;
// $model->data_key = "oil_consumption_barrels";
// $model->data_value = $val;
// $y = 1965 + $column - 1;
// $model->data_version = (string)$y;
// $model->save();
// }
// }
// }
return $this->render('index', ['model' => $model]);
}