3
<title>The source code</title>
4
<link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
5
<script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7
<body onload="prettyPrint();">
8
<pre class="prettyprint lang-js">Ext.sql.Table = function(conn, name, keyName){
11
this.keyName = keyName;
14
Ext.sql.Table.prototype = {
16
var clause = this.keyName + " = ?";
17
return this.updateBy(o, clause, [o[this.keyName]]);
20
updateBy : function(o, clause, args){
21
var sql = "UPDATE " + this.name + " set ";
24
if(o.hasOwnProperty(key)){
25
fs[fs.length] = key + ' = ?';
30
if(args.hasOwnProperty(key)){
31
a[a.length] = args[key];
34
sql = [sql, fs.join(','), ' WHERE ', clause].join('');
35
return this.conn.execBy(sql, a);
39
var sql = "INSERT into " + this.name + " ";
40
var fs = [], vs = [], a = [];
42
if(o.hasOwnProperty(key)){
48
sql = [sql, '(', fs.join(','), ') VALUES (', vs.join(','), ')'].join('');
49
return this.conn.execBy(sql, a);
52
lookup : function(id){
53
return this.selectBy('where ' + this.keyName + " = ?", [id])[0] || null;
56
exists : function(id){
57
return !!this.lookup(id);
61
if(this.exists(o[this.keyName])){
68
select : function(clause){
69
return this.selectBy(clause, null);
72
selectBy : function(clause, args){
73
var sql = "select * from " + this.name;
78
return this.conn.queryBy(sql, args);
81
remove : function(clause){
82
this.deleteBy(clause, null);
85
removeBy : function(clause, args){
86
var sql = "delete from " + this.name;
88
sql += ' where ' + clause;
91
this.conn.execBy(sql, args);
b'\\ No newline at end of file'