Пример
Код: Выделить всё
public function move(array $orders)
{
}
Как это элегантно сделать, что бы не было 100500 обновления?
Код: Выделить всё
public function move(array $orders)
{
}
Код: Выделить всё
public static function move(array $positions)
{
foreach ($positions as $position => $id) {
$model = self::findOne($id);
$model->order = $position;
$model->save(false);
}
}
Код: Выделить всё
public function massIps()
{
$count = 0;
if (empty($this->ipList))
return $count;
$data = array_map(function ($ip) {
return $data[] = [
IpHelper::encodeIp($ip),
$this->servers_id,
\Yii::$app->formatter->asDatetime('now', 'php:Y-m-d H:i:s'),
\Yii::$app->formatter->asDatetime('now', 'php:Y-m-d H:i:s'),
];
}, explode(PHP_EOL, $this->ipList));
if (sizeof($data) > 0) {
$count = \Yii::$app->db->createCommand()->batchInsert(self::tableName(), [
'ip',
'servers_id',
'created_at',
'updated_at',
], $data)->execute();
}
return $count;
}
Код: Выделить всё
$wpdb->query('INSERT INTO `' . PLUGIN_PREFIX_DB . 'counting` (`user_id`, `post_id`, `created_at`, `count`)
VALUES(' . $post->post_author . ', ' . $post_id . ', "' . date('Y-m-d') . '", ' . $count . ') ON DUPLICATE KEY UPDATE `count` = ' . $count);
Код: Выделить всё
$users = Transaction::find()->where(['status' => 10, 'product_id' => 3])->asArray()->all();
$users = ArrayHelper::getColumn($rows, 'user_id');
UserSubscribe::updateAll(['status' => 1], ['product_id'=>3, 'user_id' => $users]);