Example #1
0
 /**
  * Update column in rows by array of primary key values.
  * 
  * @param string $column
  * @param array|string $ids
  * @param array $value
  * @return bool|array
  */
 public function bulkUpdate($ids, array $data)
 {
     if (!is_array($ids)) {
         $ids = trim($ids);
         if ($ids == "") {
             return false;
         }
         $ids = [$ids];
     }
     if (count($ids) == 0) {
         return false;
     }
     $updateData = [];
     foreach ($data as $key => $value) {
         $column = isset($this->_columns[$key]) ? $this->_columns[$key] : $this->getColumnByName($key);
         if ($column === false) {
             return false;
         }
         $name = $column->getName();
         if (null !== $this->_form) {
             if (!($field = $this->_form->getFieldByKey($key))) {
                 $field = $this->_form->getFieldByName($name);
             }
             $field->setValue($value);
             $saveData = $field->getSaveData();
             $updateData[$saveData['key']] = $saveData['value'];
         } else {
             $updateData[$name] = $value;
         }
     }
     return $this->_container->update($ids, $updateData);
 }