carno-php /
mysql
| 1 | <?php |
||||||
| 2 | /** |
||||||
| 3 | * Insert data |
||||||
| 4 | * User: moyo |
||||||
| 5 | * Date: 25/12/2017 |
||||||
| 6 | * Time: 3:11 PM |
||||||
| 7 | */ |
||||||
| 8 | |||||||
| 9 | namespace Carno\Database\SQL\Actions; |
||||||
| 10 | |||||||
| 11 | use Carno\Database\Results\Created; |
||||||
| 12 | use Carno\Database\SQL\Action; |
||||||
| 13 | |||||||
| 14 | trait Insert |
||||||
| 15 | { |
||||||
| 16 | /** |
||||||
| 17 | * @param array ...$maps |
||||||
| 18 | * @return int |
||||||
| 19 | */ |
||||||
| 20 | public function insert(...$maps) |
||||||
| 21 | { |
||||||
| 22 | $this->actTrigger(Action::INSERT, $this); |
||||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||
| 23 | |||||||
| 24 | $maps && $this->data(...$maps); |
||||||
|
0 ignored issues
–
show
It seems like
data() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
The expression
$maps of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using Loading history...
|
|||||||
| 25 | |||||||
| 26 | /** |
||||||
| 27 | * @var Created $result |
||||||
| 28 | */ |
||||||
| 29 | return |
||||||
| 30 | ($result = yield $this->exec($this->sql(Action::INSERT))) instanceof Created |
||||||
|
0 ignored issues
–
show
It seems like
sql() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
It seems like
exec() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 31 | ? $result->id() |
||||||
| 32 | : 0 |
||||||
| 33 | ; |
||||||
| 34 | } |
||||||
| 35 | } |
||||||
| 36 |