Skip to content

Commit aac2899

Browse files
committed
add getTable() to update and delete
1 parent 4ce1add commit aac2899

File tree

9 files changed

+45
-2
lines changed

9 files changed

+45
-2
lines changed

docs/delete.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ Use the `from()` method to specify FROM expression.
1010
$delete->from('foo');
1111
```
1212

13+
Use the `getTable()` method to get the table being deleted from.
14+
15+
```php
16+
$table = $delete->getTable();
17+
```
18+
1319
### WHERE
1420

1521
(All `WHERE` methods support [implicit and sprintf() inline value binding](binding.md).)

docs/insert.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ Use the `into()` method to specify the table to insert into.
1010
$insert->into('foo');
1111
```
1212

13+
Use the `getTable()` method to get the table being inserted into.
14+
15+
```php
16+
$table = $insert->getTable();
17+
```
18+
1319
### Columns
1420

1521
You can set a named placeholder and its corresponding bound value using the

docs/update.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ Use the `table()` method to specify the table to update.
1010
$update->table('foo');
1111
```
1212

13+
Use the `getTable()` method to get the table being updated.
14+
15+
```php
16+
$table = $update->getTable();
17+
```
18+
1319
### Columns
1420

1521
You can set a named placeholder and its corresponding bound value using the

src/Delete.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ public function from(string $table) : static
2525
return $this;
2626
}
2727

28+
public function getTable() : string
29+
{
30+
return $this->table;
31+
}
32+
2833
public function getQueryString() : string
2934
{
3035
return $this->with->build()

src/Update.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ public function table(string $table) : static
2626
return $this;
2727
}
2828

29+
public function getTable() : string
30+
{
31+
return $this->table;
32+
}
33+
2934
public function getQueryString() : string
3035
{
3136
return $this->with->build()

tests/DeleteTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,11 @@ public function testCommon()
4848

4949
$this->assertBindValues($expect, $this->statement);
5050
}
51+
52+
public function testGetTable()
53+
{
54+
$this->statement->from('t1');
55+
$actual = $this->statement->getTable();
56+
$this->assertSame('t1', $actual);
57+
}
5158
}

tests/InsertTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ public function testCommon()
5454
$this->assertBindValues($expect, $this->statement);
5555
}
5656

57-
public function testGetTable(){
57+
public function testGetTable()
58+
{
5859
$this->statement->into('t1');
5960
$actual = $this->statement->getTable();
6061
$this->assertSame('t1', $actual);

tests/StatementTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ protected function setUp() : void
2828
$rp->setAccessible(true);
2929
}
3030

31-
$rp->setValue(0);
31+
$rp->setValue(null, 0);
3232
$this->statement = $this->newStatement();
3333
}
3434

tests/UpdateTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,11 @@ public function testHasColumns()
104104
$this->statement->columns(['c1', 'c2']);
105105
$this->assertTrue($this->statement->hasColumns());
106106
}
107+
108+
public function testGetTable()
109+
{
110+
$this->statement->table('t1');
111+
$actual = $this->statement->getTable();
112+
$this->assertSame('t1', $actual);
113+
}
107114
}

0 commit comments

Comments
 (0)