Example #1
0
 /**
  * @return Model
  **/
 public function merge(Model $model, $overwrite = false)
 {
     if (!$model->isEmpty()) {
         $vars = $model->getList();
         foreach ($vars as $name => $value) {
             if (!$overwrite && $this->has($name)) {
                 continue;
             }
             $this->set($name, $value);
         }
     }
     return $this;
 }
Example #2
0
 public function get($functionName, $linkName, $params = array(), $checkSession = true)
 {
     $positive = function ($input) {
         //$input = $input[count($input)-1];
         $result = Model::isEmpty();
         $result['content'] = array();
         foreach ($input as $inp) {
             if ($inp->getNumRows() > 0) {
                 // extract Invitation data from db answer
                 $res = Invitation::ExtractInvitation($inp->getResponse(), false);
                 $result['content'] = array_merge($result['content'], is_array($res) ? $res : array($res));
                 $result['status'] = 200;
             }
         }
         return $result;
     };
     $params = DBJson::mysql_real_escape_string($params);
     return $this->_component->call($linkName, $params, '', 200, $positive, array(), 'Model::isProblem', array(), 'Query');
 }
Example #3
0
 public function get($functionName, $linkName, $params = array(), $singleResult = false, $checkSession = true)
 {
     // in diesem Beispiel wird der Name, welcher in der Commands.json für diesen Funktionsaufruf angegeben wurde,
     // direkt Verwendet, um einen gleichnamigen Ausgang der Component.json anzusprechen und den dort
     // angegeben Aufruf auzulösen (wobei courseid entsprechend ersetzt wird)
     // diese Funktion soll aufgerufen werden, wenn unsere Anfrage an die Datenbank positiv war
     $positive = function ($input, $singleResult) {
         $result = Model::isEmpty();
         $result['content'] = array();
         foreach ($input as $inp) {
             if ($inp->getNumRows() > 0) {
                 // extract course data from db answer
                 $result['content'] = array_merge($result['content'], Course::ExtractCourse($inp->getResponse(), $singleResult));
                 $result['status'] = 200;
             }
         }
         return $result;
     };
     // hier wird eine MySql stored-procedure aufgerufen
     // dabei haben die aufzurufen Befehle die Form /funktionsname/:idA/:idB  (stehen in der Component.json)
     // dabei werden idA und idB durch die Werte in $params ersetzt Bsp.: $params = array("idA"=>2, "idB"=>3)
     $params = DBJson::mysql_real_escape_string($params);
     return $this->_component->call($linkName, $params, '', 200, $positive, array($singleResult), 'Model::isProblem', array(), 'Query');
 }
Example #4
0
 public function getSamplesInfo($callName, $input, $params = array())
 {
     $positive = function ($input) {
         $result = Model::isEmpty();
         $result['content'] = array();
         foreach ($input as $inp) {
             if ($inp->getNumRows() > 0) {
                 foreach ($inp->getResponse() as $key => $value) {
                     foreach ($value as $key2 => $value2) {
                         $result['content'][] = $value2;
                     }
                 }
                 $result['status'] = 200;
             }
         }
         return $result;
     };
     $params = DBJson::mysql_real_escape_string($params);
     return $this->_component->call($callName, $params, '', 200, $positive, array(), 'Model::isProblem', array(), 'Query');
 }