From d32f65815eb6feb4bcb8a0c85572f722d7826342 Mon Sep 17 00:00:00 2001 From: Jean-Luc Gyger Date: Mon, 18 Jan 2016 10:43:18 +0100 Subject: protect findByPk and deleteByPk with null primary key to return null for findByPk and 0 for deleteByPk --- framework/Data/DataGateway/TDataGatewayCommand.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'framework/Data') 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)); -- cgit v1.2.3