Skip to content

Commit c2dc1c5

Browse files
committed
Code style
1 parent db089d3 commit c2dc1c5

File tree

4 files changed

+32
-31
lines changed

4 files changed

+32
-31
lines changed

Tests/Unit/DeleteTest.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,6 @@
44

55
class DeleteTest extends \PHPUnit\Framework\TestCase
66
{
7-
public function testRecordDelete() : void
8-
{
9-
$table = new \Tests\App\Table\Customer();
10-
$this->assertEquals(29, $table->count());
11-
$transaction = new \PHPFUI\ORM\Transaction();
12-
$customer = new \Tests\App\Record\Customer(9);
13-
$this->assertEquals('Company I', $customer->company);
14-
$customer->delete();
15-
$this->assertEquals(28, $table->count());
16-
$this->assertTrue($transaction->rollBack());
17-
$this->assertEquals(29, $table->count());
18-
}
19-
207
public function testDeleteChildren() : void
218
{
229
$order = new \Tests\Fixtures\Record\Order(31);
@@ -31,6 +18,19 @@ public function testDeleteChildren() : void
3118
$this->assertCount(3, $orderDetailTable);
3219
}
3320

21+
public function testRecordDelete() : void
22+
{
23+
$table = new \Tests\App\Table\Customer();
24+
$this->assertEquals(29, $table->count());
25+
$transaction = new \PHPFUI\ORM\Transaction();
26+
$customer = new \Tests\App\Record\Customer(9);
27+
$this->assertEquals('Company I', $customer->company);
28+
$customer->delete();
29+
$this->assertEquals(28, $table->count());
30+
$this->assertTrue($transaction->rollBack());
31+
$this->assertEquals(29, $table->count());
32+
}
33+
3434
public function testTableDelete() : void
3535
{
3636
$table = new \Tests\App\Table\Customer();

src/PHPFUI/ORM/Children.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class Children extends \PHPFUI\ORM\VirtualField
2121
public function delete(array $parameters) : void
2222
{
2323
$table = $this->getTable(\array_shift($parameters));
24+
2425
foreach ($table->getRecordCursor() as $record)
2526
{
2627
$record->delete();

src/PHPFUI/ORM/Record.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -439,14 +439,6 @@ public function insertOrUpdate() : int | bool
439439
return $this->privateInsert(true);
440440
}
441441

442-
/**
443-
* Save the record, will either update if it exists or insert if not
444-
*/
445-
public function save() : int | bool
446-
{
447-
return $this->privateInsert(true);
448-
}
449-
450442
/**
451443
* @return bool true if loaded from the disk
452444
*/
@@ -546,6 +538,14 @@ public function reload() : bool
546538
return $this->read($keys);
547539
}
548540

541+
/**
542+
* Save the record, will either update if it exists or insert if not
543+
*/
544+
public function save() : int | bool
545+
{
546+
return $this->privateInsert(true);
547+
}
548+
549549
/**
550550
* Set a custom validator class
551551
*/

src/PHPFUI/ORM/Table.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -703,16 +703,6 @@ public function getWhereCondition() : \PHPFUI\ORM\Condition
703703
return $this->whereCondition;
704704
}
705705

706-
/**
707-
* Inserts current data into table or ignores duplicate key if found
708-
*
709-
* @param array<\PHPFUI\ORM\Record> $records
710-
*/
711-
public function insertOrIgnore(array $records) : bool
712-
{
713-
return $this->insert($records, 'ignore ');
714-
}
715-
716706
/**
717707
* Mass insertion. Does not use a transaction, so surround by a transaction if needed
718708
*
@@ -768,6 +758,16 @@ public function insert(array $records, string $ignore = '') : bool
768758
return 0 == \PHPFUI\ORM::getLastErrorCode();
769759
}
770760

761+
/**
762+
* Inserts current data into table or ignores duplicate key if found
763+
*
764+
* @param array<\PHPFUI\ORM\Record> $records
765+
*/
766+
public function insertOrIgnore(array $records) : bool
767+
{
768+
return $this->insert($records, 'ignore ');
769+
}
770+
771771
public function setDistinct(string $distinct = 'DISTINCT') : static
772772
{
773773
$this->distinct = $distinct;

0 commit comments

Comments
 (0)