summaryrefslogtreecommitdiffstats
path: root/codebase/DataStorage/ArrayDBDataWrapper.php
blob: a806161bdf05456ae8bffd16bd076dd9c5e6ee29 (plain)
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

namespace DHTMLX\Connector\DataStorage;

class ArrayDBDataWrapper extends DBDataWrapper
{
    public function get_next($res)
    {
        if ($res->index < sizeof($res->data))
            return $res->data[$res->index++];
    }

    public function select($sql)
    {
        if ($this->config->relation_id["db_name"] == "") {
            if ($sql->get_relation() == "0" || $sql->get_relation() == "") {
                return new ArrayQueryWrapper($this->connection);
            } else {
                return new ArrayQueryWrapper(array());
            }
        }

        $relation_id = $this->config->relation_id["db_name"];

        for ($i = 0; $i < count($this->connection); $i++) {
            $item = $this->connection[$i];
            if (!isset($item[$relation_id])) continue;
            if ($item[$relation_id] == $sql->get_relation())
                $result[] = $item;

        }

        return new ArrayQueryWrapper($result);
    }

    public function query($sql)
    {
        throw new Exception("Not implemented");
    }

    public function escape($value)
    {
        throw new Exception("Not implemented");
    }

    public function get_new_id()
    {
        throw new Exception("Not implemented");
    }
}