File: SelectQuery.vala

package info (click to toggle)
libgda5 5.2.4-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 75,256 kB
  • ctags: 49,218
  • sloc: ansic: 461,759; sh: 11,808; xml: 10,466; yacc: 5,160; makefile: 4,327; php: 1,416; java: 1,300; python: 896; sql: 879; perl: 116
file content (93 lines) | stat: -rw-r--r-- 2,821 bytes parent folder | download | duplicates (2)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* -*- Mode: Vala; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * libgdavala
 * Copyright (C) Daniel Espinosa Ortiz 2011 <esodan@gmail.com>
 * 
 * libgda is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * libgda is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
using Gee;
using Gda;

namespace GdaData {
    
    private class SelectQuery : GLib.Object {
        
        //private Gee.ArrayList<string> _fields;
        private SqlBuilder _sql;
        private string _table;
        
        public string table { 
        	get {
        		return this._table;
        	} 
        	set { 
        		this._table = value;
        		this._sql.select_add_target (value, null); 
        	}
        }
        
        public Connection connection { set; get; }
        
//        public SelectQuery()
//        {
//        	this._fields.add ("*");
//        	this.table = "";
//        }
//        
//        public void add_field (string field)
//        {
//        	if (this._fields.get (0) == "*")
//        	{
//        		this._fields.clear ();
//        	}
//	        
//	        this._fields.add (field);
//        }
//        
//        public SqlBuilder build ()
//        	requires (this.table != "")
//        {
//        	this._sql = new SqlBuilder (Gda.SqlStatementType.SELECT);
//        	
//        	foreach (string f in this._fields) {
//	        	this._sql.select_add_field (f, null, null);
//	        }            
//			return this._sql;
//        }
//        
//        public void set_fields_to_all () 
//        {
//        	this._fields.clear ();
//        	this._fields.add ("*");
//        }
//        
//        public void set_condition (string field, Value v, SqlOperatorType op) 
//        {
//        	var f_id = this._sql.add_id (field);
//			var e_id = this._sql.add_expr_value (null, v);
//			var c_id = this._sql.add_cond (op, f_id, e_id, 0);
//			this._sql.set_where (c_id);
//        }
//        
//        public DataModel execute () 
//            throws Error 
//            requires (this.connection.is_opened ())
//        {
//            /* Build Select Query */
//            var b = this.build ();
//		    var s = b.get_statement ();
//		    return this.connection.statement_execute_select (s, null);
//        }
    }
}