summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Luc Gyger <jean-luc.gyger@vysual.ch>2016-01-18 10:43:18 +0100
committerJean-Luc Gyger <jean-luc.gyger@vysual.ch>2016-01-18 10:43:18 +0100
commitd32f65815eb6feb4bcb8a0c85572f722d7826342 (patch)
tree0f9f96f7fb935bc4533ee255e6f849b84968017c
parent187e70938e2c18b9794b5b87116c1cb6b03901b1 (diff)
protect findByPk and deleteByPk with null primary key to return null for findByPk and 0 for deleteByPk
-rw-r--r--framework/Data/DataGateway/TDataGatewayCommand.php4
1 files changed, 4 insertions, 0 deletions
diff --git a/framework/Data/DataGateway/TDataGatewayCommand.php b/framework/Data/DataGateway/TDataGatewayCommand.php
index fb0f5df0..7ab3fcd2 100644
--- a/framework/Data/DataGateway/TDataGatewayCommand.php
+++ b/framework/Data/DataGateway/TDataGatewayCommand.php
@@ -160,6 +160,8 @@ class TDataGatewayCommand extends TComponent
*/
public function findByPk($keys)
{
+ if($keys===null)
+ return null;
list($where, $parameters) = $this->getPrimaryKeyCondition((array)$keys);
$command = $this->getBuilder()->createFindCommand($where, $parameters);
$this->onCreateCommand($command, new TSqlCriteria($where,$parameters));
@@ -196,6 +198,8 @@ class TDataGatewayCommand extends TComponent
*/
public function deleteByPk($keys)
{
+ if(count($keys)==0)
+ return 0;
$where = $this->getCompositeKeyCondition((array)$keys);
$command = $this->getBuilder()->createDeleteCommand($where);
$this->onCreateCommand($command, new TSqlCriteria($where,$keys));