select distinct
FIRST_VALUE(currency) OVER (PARTITION BY currency ORDER BY created_at desc) currency,
FIRST_VALUE(price) OVER (PARTITION BY currency ORDER BY created_at desc) price
from course
$arr = [
'2018-11-16 - test1' => [
"date" => "2018-11-16"
"type" => "test1"
"all" => "16",
"new" => "4",
"queue" => "1"
],
];
"cloo"
два значения ["cool", "looc"]
, а для остальных по одному.<?php
$data = [
"cool" => [0 => "c", 1 => "o", 2 => "o", 3 => "l"],
"looc" => [0 => "l", 1 => "o", 2 => "o", 3 => "c"],
"test" => [0 => "t", 1 => "e", 2 => "s", 3 => "t"],
"set" => [0 => "s", 1 => "e", 2 => "t"],
"get" => [0 => "g", 1 => "e", 2 => "t"]
];
$groups = [];
foreach( $data AS $k => $v) {
sort($v);
$hash = implode('', $v);
if(!isset($groups[$hash])) $groups[$hash] = [];
array_push($groups[$hash], $k);
}
$result = array_values($groups);
print_r($result);
/*
Array(
[0] => Array
(
[0] => cool
[1] => looc
)
[1] => Array
(
[0] => test
)
[2] => Array
(
[0] => set
)
[3] => Array
(
[0] => get
)
)
*/
/**
* After file save event handler.
*/
public function afterFileSave()
{
if ($this->createThumbsOnSave == true)
$this->createThumbs();
}
/**
* After file save event handler.
*/
public function createThumbs()
{
//...
}
trait AjaxValidationTrait
{
/**
* Performs ajax validation.
*
* @param Model $model
*
* @throws \yii\base\ExitException
*/
protected function performAjaxValidation(Model $model)
{
if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
Yii::$app->response->format = Response::FORMAT_JSON;
echo json_encode(ActiveForm::validate($model));
Yii::$app->end();
}
}
}
class DefaultController extends BaseAdminController
{
use AjaxValidationTrait;
public function actionCreate()
{
$model = new Point();
$this->performAjaxValidation($model);
if ($model->validate()) {
....
} else {
return $this->render('create', [
'model' => $model]
);
}
}
}
<?php $form = ActiveForm::begin([
'enableAjaxValidation' => true,
'enableClientValidation' => false,
]); ?>
$n = 3;
$m = 2;
for ($i = $n; ; $i = ($i < 7 ? $i + 1 : 1)){
echo $i . ' ';
if ($i == $m) break;
}
$n = 3;
$m = 2;
$i = $n - 1;
do {
$d = $i % 7 + 1;
echo $d . ' ';
$i++;
} while ($d != $m);
$array = [1, 2, 3, 4, 5, 6, 7];
$n = 3;
$m = 2;
$i = array_search($n, $array);
$result = array_merge(array_slice($array, $i), array_slice($array, 0, $i));
CREATE PROCEDURE `make_data`()
BEGIN
DECLARE i INT DEFAULT 1;
WHILE i < 500000 DO
<тут INSERT запрос>
SET i = i + 1;
END WHILE;
END
CALL make_data();