Example #1
0
 /**
  * Inserts relation data to config file
  * @param string $from Local table
  * @param string $to Related table
  * @param string $type Relation type
  * @param array $keys Relationed keys
  */
 protected function deleteRelationData($from, $to)
 {
     $config = Config::table($from);
     $content = $config->get();
     unset($content->relations->{$to});
     $config->put($content);
 }
Example #2
0
 /**
  * Saving inserted or updated data
  */
 public function save()
 {
     $data = $this->getData();
     if (!$this->currentId) {
         $config = $this->config();
         $config->last_id++;
         $this->set->id = $config->last_id;
         array_push($data, $this->set);
         Config::table($this->_name)->put($config);
     } else {
         $this->set->id = $this->currentId;
         $data[$this->currentKey] = $this->set;
     }
     Data::table($this->_name)->put($data);
     //         $this->setFields();
 }
Example #3
0
 static function dbSurvey()
 {
     if (self::$table != "") {
         return self::$table;
Example #4
0
 /**
  * Checking that relation between tables exists
  * @param string $local local table
  * @param string $foreign related table
  * @throws LazerException
  */
 public static function relation($local, $foreign)
 {
     $relations = Config::table($local)->relations();
     if (isset($relations->{$foreign})) {
         return TRUE;
     }
     throw new LazerException('Relation "' . $local . '" to "' . $foreign . '" doesn\'t exist');
 }