コード例 #1
0
 private function setupDatabase($params)
 {
     $sql = file_get_contents($this->config['setup']);
     if (!$sql) {
         throw new PaytoshiException(sprintf('Unable to find database sql script. Please check that %s exists.', $this->config['setup']), null);
     }
     $this->database->run($sql, $params);
 }
コード例 #2
0
 private function insertMissingFields($fields)
 {
     $existing = array_keys($this->data);
     $required = array_keys($fields);
     $newFields = array_diff($required, $existing);
     if (count($newFields) > 0) {
         $sql = sprintf("INSERT INTO `%s` (`name`, `value`) VALUES ", self::TABLE_NAME);
         $sql .= implode(', ', array_map(function ($i) {
             return "('{$i}', '')";
         }, $newFields));
         $this->database->run($sql);
     }
 }