/**
  * Generates the real table name from plugin and tablename.
  * @param iPlugin $plugin
  * @param string $tableName
  */
 protected function getTableName(iPlugin $plugin, $tableName)
 {
     return App()->getDb()->tablePrefix . strtolower($plugin->getName()) . "_{$tableName}";
 }
Example #2
0
 /**
  * 
  * @param iPlugin $plugin
  * @param string $key
  * @param mixed data Default value to return if key could not be found.
  * @param string $model Optional model name to which the data was attached.
  * @param int $id Optional id of the model instance to which the data was attached.
  * @param string $language Optional language identifier used for storing the setting.
  * 
  * @return boolean
  */
 protected function setGeneric(iPlugin $plugin, $key, $data, $model, $id, $language)
 {
     if ($id == null && $model != null) {
         throw new Exception("DbStorage::set cannot store setting for model {$model} without valid id.");
     }
     $attributes = array('plugin_id' => $plugin->getId(), 'model' => $model, 'model_id' => $id, 'key' => $key);
     $record = PluginSetting::model()->findByAttributes($attributes);
     if (is_null($record)) {
         // New setting
         $record = PluginSetting::model()->populateRecord($attributes);
         $record->setIsNewRecord(true);
     }
     $record->value = json_encode($data);
     $result = $record->save();
     return $result;
 }