Я спрашиваю как изменить
$json = '[{"id":"398",.....}]';
var_dump(json_decode($json, true));
array (size=2)
0 =>
array (size=6)
'id' => '398' (length=3)
'name' => 'цупывапывап' (length=22)
'description' => 'Дочь свергнутого короля Семи Королевств из династии Таргариенов Эйриса Безумного. ' (length=153)
'reason_murder' => 'Неприязнь' (length=18)
'killer' => 'Враждебный воин' (length=29)
'weapon' => 'Меч' (length=6)
1 =>
array (size=6)
'id' => '398' (length=3)
'name' => 'цупывапывап' (length=22)
'description' => 'Дочь свергнутого короля Семи Королевств из династии Таргариенов Эйриса Безумного. ' (length=153)
'reason_murder' => 'Неприязнь' (length=18)
'killer' => 'Враждебный воин' (length=29)
'weapon' => 'Меч' (length=6)
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=fedorov_shop',
'username' => 'fedorov_shop',
'password' => '***',
'charset' => 'utf8',
'enableSchemaCache' => true,
'schemaCacheDuration' => 3600,
]
php yii migrate --db=db
public function init()
{
$this->db = 'db2';
parent::init();
}
SELECT `username`, DATEDIFF(FROM_UNIXTIME(`updated_at`), FROM_UNIXTIME(`created_at`)) AS `date_diff` FROM `user`
Array
(
[0] => Array
(
[username] => admin
[date_diff] => 261
)
[1] => Array
(
[username] => Denis
[date_diff] => 73
)
[2] => Array
(
[username] => Vitaliy
[date_diff] => 80
)
[3] => Array
(
[username] => Elena
[date_diff] => 78
)
[4] => Array
(
[username] => Boris
[date_diff] => 0
)
[5] => Array
(
[username] => Daniel
[date_diff] => 0
)
[6] => Array
(
[username] => Vladimir
[date_diff] => 42
)
[7] => Array
(
[username] => Vasya
[date_diff] => 0
)
[8] => Array
(
[username] => Anton
[date_diff] => 0
)
[9] => Array
(
[username] => Nicolay
[date_diff] => 5
)
)
SELECT `username`, DATEDIFF(CURDATE(), FROM_UNIXTIME(`created_at`)) AS `date_diff` FROM `user`
Array
(
[0] => Array
(
[username] => admin
[date_diff] => 794
)
[1] => Array
(
[username] => Denis
[date_diff] => 616
)
[2] => Array
(
[username] => Vitaliy
[date_diff] => 515
)
[3] => Array
(
[username] => Elena
[date_diff] => 315
)
[4] => Array
(
[username] => Boris
[date_diff] => 215
)
[5] => Array
(
[username] => Daniel
[date_diff] => 200
)
[6] => Array
(
[username] => Vladimir
[date_diff] => 175
)
[7] => Array
(
[username] => Vasya
[date_diff] => 150
)
[8] => Array
(
[username] => Anton
[date_diff] => 149
)
[9] => Array
(
[username] => Nicolay
[date_diff] => 149
)
)
[
'label' => 'Дата начала подписки',
'value' => function ($model, $key, $value) {
return \kartik\date\DatePicker::widget([
'name' => 'date_subscription',
'model' => $model,
'value' => date('d-m-Y',$model->created_at),
'type' => DatePicker::TYPE_INPUT,
'pluginOptions' => [
'format' => 'yyyy-mm-dd',
'autoclose' => true,
],
]);
},
'contentOptions' => [
'onchange' => '
var Id = $(this).parent().attr("data-key");
var uDate = $(this).children("input").val();
console.log(Id + " - " + uDate);
$.ajax({
url: "'. Url::to('user/default/ajax-request') .'",
type: "POST",
data:{id: Id, date: uDate},
success: function(data){
console.log(data)
}
})
'
],
'format' => 'raw',
],
public function actionAjaxRequest()
{
if(Yii::$app->request->isAjax){
$newDate = Yii::$app->request->post('date');
$uId = Yii::$app->request->post('id');
if(($model = Users::findOne(['id' => $uId])) != null){
$model->created_at = strtotime($newDate);
if(!$model->update(false,['created_at'])){
return 'Данные не обновились.';
}
else{
return 'Данные успешно обновились.';
}
}
else{
return 'Пользователь не найден.';
}
}
return false;
}
$date = date('Y-m-d', ['delivery_date'];
Вы должны подставлять не строку, как Вы сейчас делаете, а временную метку.$date = date('Y-m-d', strtotime('delivery_date'));
sudo apt-get install -f
ALTER TABLE `comments`
ADD CONSTRAINT `fk_comments_images` FOREIGN KEY (`image_id`) REFERENCES `comments` (`id`) ON DELETE CASCADE;
SET FOREIGN_KEY_CHECKS=0;
ALTER TABLE `comments`
ADD CONSTRAINT `fk_comments_images` FOREIGN KEY (`image_id`) REFERENCES `comments` (`id`) ON DELETE CASCADE;
SET FOREIGN_KEY_CHECKS=1;
['id_no', 'default', 'value' => null]
$query = "UPDATE $table SET psevdonim='".$_POST["test_psevdonim"]."', familiya='".$_POST["test_familiya"]."' WHERE `id` = " . $_POST['id'] . "";
"SELECT * FROM my_links WHERE keyword = '".$key."' AND search = 'google' AND urlmd5 = '".$link2."'";
В БД в таблице users есть столбец status хочу что бы доступ к разделу админов имели только юзеры с статусом 3,4,5 но не совсем понимаю как это реализовать.