public function testThatTheCorrectTypesAreReturned() { $select = $this->builder->select('*'); $this->assertInstanceOf(Select::class, $select); $insert = $this->builder->insert('table'); $this->assertInstanceOf(Insert::class, $insert); $update = $this->builder->update('table'); $this->assertInstanceOf(Update::class, $update); $delete = $this->builder->delete('table'); $this->assertInstanceOf(Delete::class, $delete); $expr = $this->builder->expression(); $this->assertInstanceOf(Expression::class, $expr); }
/** * Delete records with $data where $fieldName equals to or is an element of $keys * * Note: previous WHERE clauses are preserved * * @param string $fieldName * @param mixed|array $keys */ public function deleteByField($fieldName, $keys) { $keys = (array) $keys; if (empty($keys)) { return; } //Filter relations so we don't delete records which this one only belongs to $relations = array_filter($this->entity->getRelations(), function (Relation $relation) { return !$relation instanceof Relation\BelongsTo; }); if (empty($relations)) { $this->manager->postPendingQuery(new PendingQuery($this->entity, PendingQuery::TYPE_DELETE, $this->queryBuilder->delete($this->entity->getTable())->where($this->equalsExpression($fieldName, $keys)), $this->parameters)); } else { $this->deleteRecords($this->with(array_keys($relations))->getByField($fieldName, $keys)); } }