KVStore

What?

FreePBX offers a method of storing data without maintaining tables or making direct database calls. 

Why?

  • Using the KVStore allows more flexibility in the future if there is a desire to move from mysql to another technology.

  • Using the KVStore allows you to develop without making constant changes to a table that may need to be migrated over and over.

  • The KVStore allows for uniform sanitization keeping the code more secure.

How?

Your class

<?php namespace FreePBX\modules;     class Example extends \DB_Helper{     public function __construct($freepbx = null){         if ($freepbx == null) {             throw new Exception('Not given a FreePBX Object');         }         $this->FreePBX = $freepbx;     }           public function insertSingle($key,$value){         $this->setConfig($key,$value);     }         public function getSingle($key){         return $this->getConfig($key);     }         public function deleteSingle($key){         $this->setConfig($key)     }     public function insertGroup($id, $itemsArray){         foreach($itemsArray as $key => $value){             $this->setConfig($key,$value,$id);         }     }     public function getGroup($id){         return $this->getAll($id)l     }     public function deleteGroup($id){         $this->delById($id);     } }

Return to Documentation Home I Return to Sangoma Support