-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunction.php
50 lines (42 loc) · 943 Bytes
/
function.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* Created by PhpStorm.
* User: Michal
* Date: 08.03.2016
* Time: 22:07
*/
if (session_id() == "") {
session_start();
}
require_once "config.php";
require __DIR__ . '/vendor/autoload.php';
dibi::connect([
'driver' => 'mysql',
'host' => Config::get('mysql.host'),
'username' => Config::get('mysql.user'),
'password' => Config::get('mysql.pass'),
'database' => Config::get('mysql.db_name'),
'charset' => Config::get('mysql.charset'),
]);
function dd($arr)
{
?>
<pre>
<?php
print_r($arr);
?>
</pre>
<?php
die();
}
function getQuestionResult($question_id)
{
$options = Option::fetchByQuestionId($question_id);
$sum_count = 0;
$option_items = [];
foreach($options as $option){
$sum_count += $option->count;
$option_items[$option->id] = $option->count;
}
return ['sum_count' => $sum_count, 'options' => $option_items];
}