01.28
diff
saved
hiromi2424
Note
hiromi2424 did not leave a note
hiromi2424 did not leave a note
- 1443,1496d1442
- <
- < $oldLinks = array();
- < $toDeleteLinks = array();
- <
- < if ($this->hasAndBelongsToMany[$assoc]['unique']) {
- < $conditions = array_merge(
- < array($join . '.' . $this->hasAndBelongsToMany[$assoc]['foreignKey'] => $id),
- < (array)$this->hasAndBelongsToMany[$assoc]['conditions']
- < );
- < $links = $this->{$join}->find('all', array(
- < 'conditions' => $conditions,
- < 'recursive' => empty($this->hasAndBelongsToMany[$assoc]['conditions']) ? -1 : 0,
- < 'fields' => $this->hasAndBelongsToMany[$assoc]['associationForeignKey']
- < ));
- <
- < $associationForeignKey = "{$join}." . $this->hasAndBelongsToMany[$assoc]['associationForeignKey'];
- < $oldLinks = Set::extract($links, "{n}.{$associationForeignKey}");
- <
- < $toDeleteLinks = array();
- <
- < $newLinks = array();
- < foreach((array)$data as $row){
- < $newLink = null;
- <
- < if ((is_string($row) && (strlen($row) == 36 || strlen($row) == 16)) || is_numeric($row)) {
- < $newLink = $row;
- < } elseif (isset($row[$this->hasAndBelongsToMany[$assoc]['associationForeignKey']])) {
- < if(isset($row[$this->{$join}->primaryKey])){
- < continue;
- < }
- < $newLink = $row[$this->hasAndBelongsToMany[$assoc]['associationForeignKey']];
- < } elseif (isset($row[$join]) && isset($row[$join][$this->hasAndBelongsToMany[$assoc]['associationForeignKey']])) {
- < if(isset($row[$join][$this->{$join}->primaryKey])){
- < continue;
- < }
- < $newLink = $row[$join][$this->hasAndBelongsToMany[$assoc]['associationForeignKey']];
- < }
- <
- < if(!$newLink){
- < continue;
- < }
- <
- < $newLinks[] = $newLink;
- < }
- < $newLinks = array_unique($newLinks);
- <
- < $toDeleteLinks = array_diff($oldLinks,$newLinks);
- <
- < if (!empty($toDeleteLinks)) {
- < $conditions[$associationForeignKey] = $toDeleteLinks;
- < $db->delete($this->{$join}, $conditions);
- < }
- < }
- <
- 1499,1501d1444
- < if(in_array($row,$oldLinks)){
- < continue;
- < }
- 1513,1516d1455
- < if(in_array($row[$this->hasAndBelongsToMany[$assoc]['associationForeignKey']],$oldLinks)
- < && !isset($row[$this->{$join}->primaryKey]) ){
- < continue;
- < }
- 1519,1522d1457
- < if(in_array($row[$join][$this->hasAndBelongsToMany[$assoc]['associationForeignKey']],$oldLinks)
- < && !isset($row[$join][$this->{$join}->primaryKey]) ){
- < continue;
- < }
- 1526c1461,1479
- <
- ---
- >
- > if ($this->hasAndBelongsToMany[$assoc]['unique']) {
- > $conditions = array_merge(
- > array($join . '.' . $this->hasAndBelongsToMany[$assoc]['foreignKey'] => $id),
- > (array)$this->hasAndBelongsToMany[$assoc]['conditions']
- > );
- > $links = $this->{$join}->find('all', array(
- > 'conditions' => $conditions,
- > 'recursive' => empty($this->hasAndBelongsToMany[$assoc]['conditions']) ? -1 : 0,
- > 'fields' => $this->hasAndBelongsToMany[$assoc]['associationForeignKey']
- > ));
- >
- > $associationForeignKey = "{$join}." . $this->hasAndBelongsToMany[$assoc]['associationForeignKey'];
- > $oldLinks = Set::extract($links, "{n}.{$associationForeignKey}");
- > if (!empty($oldLinks)) {
- > $conditions[$associationForeignKey] = $oldLinks;
- > $db->delete($this->{$join}, $conditions);
- > }
- > }
- 1540d1492
- <
Parsed in 0.028 seconds, using GeSHi 1.0.7.14