diff -urw dam_catedit.orig/lib/class.tx_damcatedit_db.php dam_catedit/lib/class.tx_damcatedit_db.php --- dam_catedit.orig/lib/class.tx_damcatedit_db.php 2006-05-15 21:42:15.000000000 +0200 +++ dam_catedit/lib/class.tx_damcatedit_db.php 2006-05-15 22:46:46.000000000 +0200 @@ -217,9 +217,9 @@ $fields = $fields?$fields:$this->fieldList; $rows = array(); - $res = mysql(TYPO3_db, 'SELECT '.$fields.' FROM '.$this->table.' WHERE uid IN ('.$uids.')'.$where.$this->where_default.$this->pidListWhere.($sorting?$this->sorting:'')); - echo mysql_error(); - while ($row = mysql_fetch_assoc($res)) { + $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, $this->table, 'uid IN ('.$uids.')'.$where.$this->where_default.$this->pidListWhere, '', ($sorting?$this->sorting:'')); + if(!$res) echo $GLOBALS['TYPO3_DB']->sql_error(); + while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $rows[$row['uid']]=$row; } return $rows; @@ -282,13 +282,13 @@ function getSubRecords ($uid, $fields='', $where='', $sorting=true) { $fields = $fields?$fields:$this->fieldList; - $res = mysql(TYPO3_db, 'SELECT '.$fields.' FROM '.$this->table.' WHERE '.$this->parentField.'='.intval($uid).$where.$this->where_default.$this->pidListWhere.($sorting?$this->sorting:'')); - echo mysql_error(); + $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, $this->table, $this->parentField.'='.intval($uid).$where.$this->where_default.$this->pidListWhere, '', ($sorting?$this->sorting:'')); + if(!$res) echo $GLOBALS['TYPO3_DB']->sql_error(); if($this->resReturn) return $res; $rows = array(); - while ($row = mysql_fetch_assoc($res)) { + while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $rows[$row['uid']]=$row; } return $rows; @@ -409,10 +409,9 @@ $theList=''; if ($uid && $depth>0) { - $query = 'SELECT uid FROM '.$this->table.' WHERE '.$this->parentField.'='.intval($uid).$where.$this->where_default.$this->sorting; - $res = mysql(TYPO3_db, $query); - echo mysql_error(); - while ($row = mysql_fetch_assoc($res)) { + $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', $this->table, $this->parentField.'='.intval($uid).$where.$this->where_default, '', $this->sorting); + if(!$res) echo $GLOBALS['TYPO3_DB']->sql_error(); + while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { if ($beginLevel<=0) { $theList.=$row['uid'].','; } @@ -448,15 +447,15 @@ $uid = intval($uid); while ($uid!=0 && $loopCheck>0) { $loopCheck--; - $res = mysql(TYPO3_db, 'SELECT '.$selFields.' FROM '.$this->table.' WHERE uid='.intval($uid).$where.$this->where_default); - if ($row = mysql_fetch_assoc($res)) { + $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($selFields, $this->table, 'uid='.intval($uid).$where.$this->where_default); + if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { if (count($MPA)) { $curMP=end($MPA); if (!strcmp($row['uid'],$curMP[0])) { array_pop($MPA); - $res = mysql(TYPO3_db, 'SELECT '.$selFields.' FROM '.$this->table.' WHERE uid='.intval($curMP[1]).$where.$this->where_default); - $row = mysql_fetch_assoc($res); + $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($selFields, $this->table, 'uid='.intval($curMP[1]).$where.$this->where_default); + $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); $row['_MOUNTED_FROM']=$curMP[0]; if (!is_array($row)) return array(); // error - no record... } @@ -508,20 +507,18 @@ function writeMM($dataRecordUid,$treeRecordUid) { // delete all relations: - $uid = intval($uid); - $query='DELETE FROM '.$this->mm_table.' WHERE uid_local='.$dataRecordUid.' AND foreign_uid='.$treeRecordUid; - $query.=$this->mm_prependTableName?' AND tablenames=\''.$this->table.'\'':''; - - $res=mysql(TYPO3_db,$query); + $res = $GLOBALS['TYPO3_DB']->exec_DELETEquery($this->mm_table, 'uid_local='.(int)$dataRecordUid.' AND foreign_uid='.(int)$treeRecordUid.($this->mm_prependTableName?' AND tablenames='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->table,$this->mm_table):'')); + $sort=0; // what to set here??? + $data = array( + 'uid_local' => $dataRecordUid, + 'uid_foreign' => $treeRecordUid, + 'sorting' => $sort, + ); if ($this->mm_prependTableName) { - $prependTable=',tablenames'; - $prependTableName=',\''.addslashes($this->table).'\''; + $data['tablenames'] = $this->table; } - $sort=0; // what to set here??? - $query='INSERT INTO '.$this->mm_table.' (uid_local,uid_foreign,sorting'.$prependTable.') VALUES (\''.$dataRecordUid.'\',\''.$treeRecordUid.'\','.$sort.$prependTableName.')'; - - $res=mysql(TYPO3_db,$query); + $GLOBALS['TYPO3_DB']->exec_INSERTquery($this->mm_table, $data); // !!!!!! update the relation counter in the data table