Пример #1
0
 /**
  * @param $object         object
  * @param $foreign_object object
  * @return string
  */
 public function buildQuery($object, $foreign_object)
 {
     list($table, $field1, $field2, $id1, $id2) = Map::sqlElementsOf($object, $this->property, $foreign_object);
     if ($this->property->getType()->getElementTypeAsString() == 'object') {
         $class_field = substr($field2, 3) . '_class';
         return 'INSERT INTO' . SP . BQ . $table . BQ . LF . 'SET ' . $field1 . ' = ' . $id1 . ', ' . $field2 . ' = ' . $id2 . ', ' . $class_field . ' = ' . Value::escape(get_class($foreign_object));
     } else {
         return 'INSERT INTO' . SP . BQ . $table . BQ . LF . 'SET ' . $field1 . ' = ' . $id1 . ', ' . $field2 . ' = ' . $id2;
     }
 }
Пример #2
0
 /**
  * @param $object         object
  * @param $foreign_object object
  * @return string
  */
 public function buildQuery($object, $foreign_object)
 {
     list($table, $field1, $field2, $id1, $id2) = Map::sqlElementsOf($object, $this->property, $foreign_object);
     return 'DELETE FROM ' . BQ . $table . BQ . LF . 'WHERE ' . BQ . $field1 . BQ . ' = ' . $id1 . ' AND ' . BQ . $field2 . BQ . ' = ' . $id2;
 }