atk4\data\tests\SQLTestCase::getDB PHP Method

getDB() public method

public getDB ( $tables = null, $noid = false )
    public function getDB($tables = null, $noid = false)
    {
        if (!$tables) {
            $tables = $this->tables;
        }
        if (is_string($tables)) {
            $tables = array_map('trim', explode(',', $tables));
        }
        $ret = [];
        foreach ($tables as $table) {
            $data2 = [];
            $s = new Query(['connection' => $this->db->connection]);
            $data = $s->table($table)->get();
            foreach ($data as &$row) {
                foreach ($row as &$val) {
                    if (is_int($val)) {
                        $val = (int) $val;
                    }
                }
                if ($noid) {
                    unset($row['id']);
                    $data2[] = $row;
                } else {
                    $data2[$row['id']] = $row;
                }
            }
            $ret[$table] = $data2;
        }
        return $ret;
    }