Merge branch 'development' into 'master'
Development See merge request !8
This commit is contained in:
commit
5abff99764
|
@ -2,6 +2,7 @@
|
||||||
namespace Westdc\Db;
|
namespace Westdc\Db;
|
||||||
|
|
||||||
use Westdc\Helpers\Assist as view;
|
use Westdc\Helpers\Assist as view;
|
||||||
|
use Westdc\Helpers\Assist;
|
||||||
|
|
||||||
class Dbh
|
class Dbh
|
||||||
{
|
{
|
||||||
|
@ -24,7 +25,7 @@ class Dbh
|
||||||
foreach($data as $k=>$v)
|
foreach($data as $k=>$v)
|
||||||
{
|
{
|
||||||
$fields[] = '"'.$k.'"';
|
$fields[] = '"'.$k.'"';
|
||||||
if(is_int($v) || is_float($v) || is_bool($v))
|
if(is_int($v) || is_float($v) || is_bool($v) || $v === "NULL")
|
||||||
{
|
{
|
||||||
$datas[] = $v;
|
$datas[] = $v;
|
||||||
}else{
|
}else{
|
||||||
|
@ -81,7 +82,7 @@ class Dbh
|
||||||
|
|
||||||
foreach($data as $k=>$v)
|
foreach($data as $k=>$v)
|
||||||
{
|
{
|
||||||
if(is_int($v) || is_float($v) || is_bool($v))
|
if(is_int($v) || is_float($v) || is_bool($v) || $v === "NULL")
|
||||||
{
|
{
|
||||||
$ups[] = '"'.$k.'"='.$v;
|
$ups[] = '"'.$k.'"='.$v;
|
||||||
}else{
|
}else{
|
||||||
|
@ -122,6 +123,7 @@ class Dbh
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$sql = "UPDATE \"".$table."\" SET $fields $wheresql RETURNING id";
|
$sql = "UPDATE \"".$table."\" SET $fields $wheresql RETURNING id";
|
||||||
|
//exit($sql);
|
||||||
try{
|
try{
|
||||||
$sth = $this->db->prepare($sql);
|
$sth = $this->db->prepare($sql);
|
||||||
if($sth->execute())
|
if($sth->execute())
|
||||||
|
@ -136,7 +138,7 @@ class Dbh
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}else{
|
}else{
|
||||||
echo view::Dump('Caught exception: '. $e->getMessage(). "\n"."SQL:".$sql,false);
|
echo Assist::Dump('Caught exception: '. $e->getMessage(). "\n"."SQL:".$sql,false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,9 +83,22 @@ class Record extends AbstractEventManager {
|
||||||
$id = $dbh->update($table,$data,$where,true);
|
$id = $dbh->update($table,$data,$where,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
elseif($where instanceof Sql\Where)
|
elseif($where instanceof Sql\Where || is_callable($where))
|
||||||
{
|
{
|
||||||
|
try{
|
||||||
|
$adapter = Db::getInstance();
|
||||||
|
|
||||||
|
$sql = new Sql\Sql($adapter);
|
||||||
|
|
||||||
|
$update = $sql->update($table);
|
||||||
|
$update->where($where);
|
||||||
|
$update->set($data);
|
||||||
|
|
||||||
|
$statement = $sql->prepareStatementForSqlObject($update);
|
||||||
|
return $statement->execute();
|
||||||
|
}catch (\Exception $e){
|
||||||
|
throw new RecordException($e->getMessage(),$e->getCode());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
elseif(is_array($where))
|
elseif(is_array($where))
|
||||||
|
|
|
@ -112,7 +112,7 @@ class Upload extends AbstractEventManager implements ServiceManagerAwareInterfac
|
||||||
|
|
||||||
$this->makeDateDir();
|
$this->makeDateDir();
|
||||||
|
|
||||||
if(empty($this->fileName) || empty($fileName))
|
if(empty($this->fileName) && empty($fileName))
|
||||||
$this->setFileName(NULL , $fileService->getFileTextExt($files['name']));
|
$this->setFileName(NULL , $fileService->getFileTextExt($files['name']));
|
||||||
|
|
||||||
if(!empty($fileName))
|
if(!empty($fileName))
|
||||||
|
@ -289,24 +289,14 @@ class Upload extends AbstractEventManager implements ServiceManagerAwareInterfac
|
||||||
*/
|
*/
|
||||||
public function setFileName($fileName,$fileExt = "")
|
public function setFileName($fileName,$fileExt = "")
|
||||||
{
|
{
|
||||||
if(!empty($fileName)){
|
|
||||||
|
|
||||||
if(empty($fileExt))
|
|
||||||
{
|
|
||||||
$fileExt = pathinfo($fileName,PATHINFO_EXTENSION);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(empty($fileExt))
|
|
||||||
$this->fileName = $fileName;
|
|
||||||
else
|
|
||||||
$this->fileName = $fileName . "." .$fileExt;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$tools = $this->serviceManager->get('Tools');
|
$tools = $this->serviceManager->get('Tools');
|
||||||
$this->fileUuid = $uuid = $tools->uuid();
|
$this->fileUuid = $uuid = $tools->uuid();
|
||||||
|
|
||||||
|
if(!empty($fileName)){
|
||||||
|
$this->fileName = $fileName;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(empty($fileExt))
|
if(empty($fileExt))
|
||||||
$this->fileName = $uuid;
|
$this->fileName = $uuid;
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue