01.28
diff
saved
hiromi2424
Note
hiromi2424 did not leave a note
hiromi2424 did not leave a note
- 1442a1443,1496
- >
- > $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);
- > }
- > }
- >
- 1444a1499,1501
- > if(in_array($row,$oldLinks)){
- > continue;
- > }
- 1455a1513,1516
- > if(in_array($row[$this->hasAndBelongsToMany[$assoc]['associationForeignKey']],$oldLinks)
- > && !isset($row[$this->{$join}->primaryKey]) ){
- > continue;
- > }
- 1457a1519,1522
- > if(in_array($row[$join][$this->hasAndBelongsToMany[$assoc]['associationForeignKey']],$oldLinks)
- > && !isset($row[$join][$this->{$join}->primaryKey]) ){
- > continue;
- > }
- 1461,1479c1526
- <
- < 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);
- < }
- < }
- ---
- >
- 1492a1540
- >
Parsed in 0.028 seconds, using GeSHi 1.0.7.14