3
* Copyright(c) 2006-2008, Ext JS, LLC.
6
* http://extjs.com/license
9
Ext.sql.Table = function(conn, name, keyName){
12
this.keyName = keyName;
15
Ext.sql.Table.prototype = {
17
var clause = this.keyName + " = ?";
18
return this.updateBy(o, clause, [o[this.keyName]]);
21
updateBy : function(o, clause, args){
22
var sql = "UPDATE " + this.name + " set ";
25
if(o.hasOwnProperty(key)){
26
fs[fs.length] = key + ' = ?';
31
if(args.hasOwnProperty(key)){
32
a[a.length] = args[key];
35
sql = [sql, fs.join(','), ' WHERE ', clause].join('');
36
return this.conn.execBy(sql, a);
40
var sql = "INSERT into " + this.name + " ";
41
var fs = [], vs = [], a = [];
43
if(o.hasOwnProperty(key)){
49
sql = [sql, '(', fs.join(','), ') VALUES (', vs.join(','), ')'].join('');
50
return this.conn.execBy(sql, a);
53
lookup : function(id){
54
return this.selectBy('where ' + this.keyName + " = ?", [id])[0] || null;
57
exists : function(id){
58
return !!this.lookup(id);
62
if(this.exists(o[this.keyName])){
69
select : function(clause){
70
return this.selectBy(clause, null);
73
selectBy : function(clause, args){
74
var sql = "select * from " + this.name;
79
return this.conn.queryBy(sql, args);
82
remove : function(clause){
83
this.deleteBy(clause, null);
86
removeBy : function(clause, args){
87
var sql = "delete from " + this.name;
89
sql += ' where ' + clause;
92
this.conn.execBy(sql, args);
b'\\ No newline at end of file'