@@ -81,20 +81,35 @@ function getColumns($table) {
81
81
* Get a row from a table.
82
82
* @param str table
83
83
* @param str where
84
+ * @param str[] contains requested columns
84
85
* @return resource A resultset resource
85
86
*/
86
- function getRow ($ table , $ where ) {
87
- return mysql_query (sprintf ('SELECT * FROM %s WHERE %s ' , $ table , $ where ));
87
+ function getRow ($ table , $ where , $ fields = NULL ) {
88
+ $ inject = '' ;
89
+ if ($ fields == NULL ) $ inject = "* " ;
90
+ else {
91
+ $ fieldnames = explode (', ' , $ fields );
92
+ foreach ($ fieldnames as $ field ) {
93
+ $ inject .= $ field . ', ' ;
94
+ }
95
+ // remove redundant comma
96
+ $ inject = substr ($ inject , 0 , strlen ($ inject )-1 );
97
+ }
98
+ return mysql_query (sprintf ('SELECT %s FROM %s WHERE %s ' , $ inject , $ table , $ where ));
88
99
}
89
100
90
101
/**
91
102
* Get the rows in a table.
92
103
* @param str primary The names of the primary columns to return
93
104
* @param str table
105
+ * @param int from lowerbound for the LIMIT
106
+ * @param int to denoting the interval starting at lowerbound
107
+ * @param str[] sort contains columns for sorting purposes
108
+ * @param str[] filter contains search criteria for the rows
94
109
* @return resource A resultset resource
95
110
*/
96
- function getTable ($ primary , $ table ) {
97
- return mysql_query (sprintf ('SELECT %s FROM %s ' , $ primary , $ table ));
111
+ function getTable ($ primary , $ table, $ from , $ to , $ sort = NULL , $ filter = NULL ) {
112
+ return mysql_query (sprintf ('SELECT %s FROM %s LIMIT %d, %d ' , $ primary , $ table, $ from , $ to ));
98
113
}
99
114
100
115
/**
0 commit comments