| @@ 269-283 (lines=15) @@ | ||
| 266 | * |
|
| 267 | * @return bool |
|
| 268 | */ |
|
| 269 | public function addConfig($name, $value) |
|
| 270 | { |
|
| 271 | $insert = sprintf( |
|
| 272 | "INSERT INTO |
|
| 273 | %sfaqinstances_config |
|
| 274 | VALUES |
|
| 275 | (%d, '%s', '%s')", |
|
| 276 | PMF_Db::getTablePrefix(), |
|
| 277 | $this->getId(), |
|
| 278 | $this->config->getDb()->escape(trim($name)), |
|
| 279 | $this->config->getDb()->escape(trim($value)) |
|
| 280 | ); |
|
| 281 | ||
| 282 | return $this->config->getDb()->query($insert); |
|
| 283 | } |
|
| 284 | ||
| 285 | /** |
|
| 286 | * Returns the configuration value. |
|
| @@ 131-145 (lines=15) @@ | ||
| 128 | * |
|
| 129 | * @return bool |
|
| 130 | */ |
|
| 131 | public function set($key, $value) |
|
| 132 | { |
|
| 133 | $query = sprintf("UPDATE %s%s SET config_value = '%s' WHERE config_name = '%s'", |
|
| 134 | PMF_Db::getTablePrefix(), |
|
| 135 | $this->_tableName, |
|
| 136 | $this->getDb()->escape(trim($value)), |
|
| 137 | $this->getDb()->escape(trim($key)) |
|
| 138 | ); |
|
| 139 | ||
| 140 | return $this->getDb()->query($query); |
|
| 141 | } |
|
| 142 | ||
| 143 | /** |
|
| 144 | * Sets the PMF_DB_Driver object. |
|
| 145 | * |
|
| 146 | * @param PMF_DB_Driver $database |
|
| 147 | */ |
|
| 148 | public function setDb(PMF_DB_Driver $database) |
|
| @@ 318-332 (lines=15) @@ | ||
| 315 | * |
|
| 316 | * @return bool |
|
| 317 | */ |
|
| 318 | public function add($name, $value) |
|
| 319 | { |
|
| 320 | $insert = sprintf( |
|
| 321 | "INSERT INTO |
|
| 322 | %s%s |
|
| 323 | VALUES |
|
| 324 | ('%s', '%s')", |
|
| 325 | PMF_Db::getTablePrefix(), |
|
| 326 | $this->_tableName, |
|
| 327 | $this->getDb()->escape(trim($name)), |
|
| 328 | $this->getDb()->escape(trim($value)) |
|
| 329 | ); |
|
| 330 | ||
| 331 | return $this->getDb()->query($insert); |
|
| 332 | } |
|
| 333 | ||
| 334 | /** |
|
| 335 | * Deletes a configuration item for the database. |
|
| @@ 341-354 (lines=14) @@ | ||
| 338 | * |
|
| 339 | * @return bool |
|
| 340 | */ |
|
| 341 | public function delete($name) |
|
| 342 | { |
|
| 343 | $delete = sprintf( |
|
| 344 | "DELETE FROM |
|
| 345 | %s%s |
|
| 346 | WHERE |
|
| 347 | config_name = '%s'", |
|
| 348 | PMF_Db::getTablePrefix(), |
|
| 349 | $this->_tableName, |
|
| 350 | $this->getDb()->escape(trim($name)) |
|
| 351 | ); |
|
| 352 | ||
| 353 | return $this->getDb()->query($delete); |
|
| 354 | } |
|
| 355 | ||
| 356 | /** |
|
| 357 | * Updates all configuration items. |
|