Revert "改名"
This reverts commit fdf58326
This commit is contained in:
+5
-8
@@ -166,15 +166,12 @@ class Collection extends AbstractCollection
|
||||
public function delete(): bool
|
||||
{
|
||||
$model = $this->getModel();
|
||||
if (!$model->hasPrimary()) return false;
|
||||
$ids = [];
|
||||
foreach ($this as $item) {
|
||||
$id = $item->getPrimaryValue();
|
||||
if (!empty($id)) {
|
||||
$ids[] = $id;
|
||||
}
|
||||
if ($model->hasPrimary()) {
|
||||
$key = $model->getPrimary();
|
||||
|
||||
return $model::query()->whereIn($key, $this->column($key))->delete();
|
||||
}
|
||||
return $model::query()->whereIn($model->getPrimary(), $ids)->delete();
|
||||
throw new Exception('Must set primary key. if you wante delete');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+5
-5
@@ -75,11 +75,11 @@ class Connection extends Component
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->eventProvider->on(OnWorkerStop::class, [$this, 'clear_connection'], 0);
|
||||
$this->eventProvider->on(OnWorkerExit::class, [$this, 'clear_connection'], 0);
|
||||
$this->eventProvider->on(BeginTransaction::class, [$this, 'beginTransaction'], 0);
|
||||
$this->eventProvider->on(Rollback::class, [$this, 'rollback'], 0);
|
||||
$this->eventProvider->on(Commit::class, [$this, 'commit'], 0);
|
||||
$this->getEventProvider()->on(OnWorkerStop::class, [$this, 'clear_connection'], 0);
|
||||
$this->getEventProvider()->on(OnWorkerExit::class, [$this, 'clear_connection'], 0);
|
||||
$this->getEventProvider()->on(BeginTransaction::class, [$this, 'beginTransaction'], 0);
|
||||
$this->getEventProvider()->on(Rollback::class, [$this, 'rollback'], 0);
|
||||
$this->getEventProvider()->on(Commit::class, [$this, 'commit'], 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,9 +28,9 @@ class DatabasesProviders extends Providers
|
||||
*/
|
||||
public function onImport(Application $application)
|
||||
{
|
||||
$this->eventProvider->on(OnWorkerStart::class, [$this, 'createPool']);
|
||||
$this->eventProvider->on(OnProcessStart::class, [$this, 'createPool']);
|
||||
$this->eventProvider->on(OnTaskerStart::class, [$this, 'createPool']);
|
||||
$this->getEventProvider()->on(OnWorkerStart::class, [$this, 'createPool']);
|
||||
$this->getEventProvider()->on(OnProcessStart::class, [$this, 'createPool']);
|
||||
$this->getEventProvider()->on(OnTaskerStart::class, [$this, 'createPool']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+11
-5
@@ -32,11 +32,11 @@ interface ModelInterface
|
||||
public static function find(string|int $param): mixed;
|
||||
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return static
|
||||
*/
|
||||
public static function populate(array $data): static;
|
||||
/**
|
||||
* @param array $data
|
||||
* @return static
|
||||
*/
|
||||
public static function populate(array $data): static;
|
||||
|
||||
|
||||
/**
|
||||
@@ -46,6 +46,12 @@ interface ModelInterface
|
||||
public static function query(): ActiveQuery;
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPrimary(): string;
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user