forked from Wavyzz/dolibarr
Fix sql syntax error
This commit is contained in:
@@ -8445,7 +8445,7 @@ abstract class CommonObject
|
|||||||
/**
|
/**
|
||||||
* Delete related files of object in database
|
* Delete related files of object in database
|
||||||
*
|
*
|
||||||
* @param integer $mode 0=Use path to find record, 1=Use src_object_xxx fields
|
* @param integer $mode 0=Use path to find record, 1=Use src_object_xxx fields (Mode 1 is recommanded for new objects)
|
||||||
* @return bool True if OK, False if KO
|
* @return bool True if OK, False if KO
|
||||||
*/
|
*/
|
||||||
public function deleteEcmFiles($mode = 0)
|
public function deleteEcmFiles($mode = 0)
|
||||||
@@ -8503,7 +8503,7 @@ abstract class CommonObject
|
|||||||
// Delete in database with mode 1
|
// Delete in database with mode 1
|
||||||
if ($mode == 1) {
|
if ($mode == 1) {
|
||||||
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."ecm_files_extrafields";
|
$sql = 'DELETE FROM '.MAIN_DB_PREFIX."ecm_files_extrafields";
|
||||||
$sql .= " WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX."ecm_files WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".$this->id;
|
$sql .= " WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX."ecm_files WHERE src_object_type = '".$this->db->escape($this->table_element.(empty($this->module) ? '' : '@'.$this->module))."' AND src_object_id = ".$this->id.")";
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (!$resql) {
|
if (!$resql) {
|
||||||
$this->error = $this->db->lasterror();
|
$this->error = $this->db->lasterror();
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ class MyObjectTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A sample test
|
* A sample test
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function testSomething()
|
public function testSomething()
|
||||||
@@ -139,4 +140,53 @@ class MyObjectTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testMyObjectCreate
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function testMyObjectCreate()
|
||||||
|
{
|
||||||
|
global $conf,$user,$langs,$db;
|
||||||
|
$conf=$this->savconf;
|
||||||
|
$user=$this->savuser;
|
||||||
|
$langs=$this->savlangs;
|
||||||
|
$db=$this->savdb;
|
||||||
|
|
||||||
|
$localobject=new MyObject($this->savdb);
|
||||||
|
$localobject->initAsSpecimen();
|
||||||
|
$result=$localobject->create($user);
|
||||||
|
|
||||||
|
print __METHOD__." result=".$result."\n";
|
||||||
|
$this->assertLessThan($result, 0);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testMyObjectDelete
|
||||||
|
*
|
||||||
|
* @param int $id Id of object
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @depends testMyObjectCreate
|
||||||
|
* The depends says test is run only if previous is ok
|
||||||
|
*/
|
||||||
|
public function testMyObjectDelete($id)
|
||||||
|
{
|
||||||
|
global $conf,$user,$langs,$db;
|
||||||
|
$conf=$this->savconf;
|
||||||
|
$user=$this->savuser;
|
||||||
|
$langs=$this->savlangs;
|
||||||
|
$db=$this->savdb;
|
||||||
|
|
||||||
|
$localobject=new MyObject($this->savdb);
|
||||||
|
$result=$localobject->fetch($id);
|
||||||
|
$result=$localobject->delete($user);
|
||||||
|
|
||||||
|
print __METHOD__." id=".$id." result=".$result."\n";
|
||||||
|
$this->assertLessThan($result, 0);
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,4 +148,30 @@ class BOMTest extends PHPUnit\Framework\TestCase
|
|||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testBOMDelete
|
||||||
|
*
|
||||||
|
* @param int $id Id of object
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @depends testBOMCreate
|
||||||
|
* The depends says test is run only if previous is ok
|
||||||
|
*/
|
||||||
|
public function testBOMDelete($id)
|
||||||
|
{
|
||||||
|
global $conf,$user,$langs,$db;
|
||||||
|
$conf=$this->savconf;
|
||||||
|
$user=$this->savuser;
|
||||||
|
$langs=$this->savlangs;
|
||||||
|
$db=$this->savdb;
|
||||||
|
|
||||||
|
$localobject=new BOM($this->savdb);
|
||||||
|
$result=$localobject->fetch($id);
|
||||||
|
$result=$localobject->delete($user);
|
||||||
|
|
||||||
|
print __METHOD__." id=".$id." result=".$result."\n";
|
||||||
|
$this->assertLessThan($result, 0);
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user