@@ -520,32 +520,28 @@ public function save(array $options = []){
520520 // Get current values as stored in DB
521521 $ db_settings = $ this ->fetchSettings ();
522522
523- $ db = Capsule::connection ()->getPdo ();
524-
525- $ table = $ this ->table ;
526-
527- $ stmt_insert = $ db ->prepare ("INSERT INTO ` $ table`
528- (plugin, name, value, description)
529- VALUES (:plugin, :name, :value, :description); " );
530-
531- $ stmt_update = $ db ->prepare ("UPDATE ` $ table` SET
532- value = :value,
533- description = :description
534- WHERE plugin = :plugin and name = :name; " );
535-
536523 // For each setting in this object, check if it exists in DB. If it does not exist, add. If it exists and is different from the current value, update.
537524 foreach ($ this ->_settings as $ plugin => $ setting ){
538525 foreach ($ setting as $ name => $ value ){
539- $ sqlVars = [
540- ":plugin " => $ plugin ,
541- ":name " => $ name ,
542- ":value " => $ value ,
543- ":description " => $ this ->_descriptions [$ plugin ][$ name ]
544- ];
545526 if (!isset ($ db_settings ['settings ' ][$ plugin ]) || !isset ($ db_settings ['settings ' ][$ plugin ][$ name ])){
546- $ stmt_insert ->execute ($ sqlVars );
527+ Capsule::table ($ this ->table )->insert (
528+ [
529+ 'plugin ' => $ plugin ,
530+ 'name ' => $ name ,
531+ 'value ' => $ value ,
532+ 'description ' => $ this ->_descriptions [$ plugin ][$ name ]
533+ ]
534+ );
547535 } else if (($ db_settings ['settings ' ][$ plugin ][$ name ] !== $ this ->_settings [$ plugin ][$ name ]) || ($ db_settings ['descriptions ' ][$ plugin ][$ name ] !== $ this ->_descriptions [$ plugin ][$ name ])){
548- $ stmt_update ->execute ($ sqlVars );
536+ Capsule::table ($ this ->table )
537+ ->where ('plugin ' , $ plugin )
538+ ->where ('name ' , $ name )
539+ ->update (
540+ [
541+ 'value ' => $ value ,
542+ 'description ' => $ this ->_descriptions [$ plugin ][$ name ]
543+ ]
544+ );
549545 }
550546 }
551547 }
0 commit comments