Newer
Older
if(stristr($type, 'text')) $metaType = 'text';
if(stristr($type, 'double')) $metaType = 'double';
if(stristr($type, 'blob')) $metaType = 'blob';
$column['type'] = $metaType;
$columns[] = $column;
}
return $columns;
} else {
return false;
}
//$this->createTable('tester',$columns);
$result = mysql_list_fields($go_info["server"]["db_name"],$table_name);
$fields = mysql_num_fields ($result);
$i = 0;
$table = mysql_field_table ($result, $i);
while ($i < $fields) {
$name = mysql_field_name ($result, $i);
$type = mysql_field_type ($result, $i);
$len = mysql_field_len ($result, $i);
$flags = mysql_field_flags ($result, $i);
print_r($flags);
$columns = array(name => $name,
type => "",
defaultValue => "",
isnull => 1,
option => "");
$returnvar[] = $columns;
$i++;
}
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
}
public function mapType($metaType, $typeValue) {
global $go_api;
$metaType = strtolower($metaType);
switch ($metaType) {
case 'int16':
return 'smallint';
break;
case 'int32':
return 'int';
break;
case 'int64':
return 'bigint';
break;
case 'double':
return 'double';
break;
case 'char':
return 'char';
break;
case 'varchar':
if($typeValue < 1) die('Database failure: Length required for these data types.');
return 'varchar('.$typeValue.')';
break;
case 'text':
return 'text';
break;
case 'blob':
return 'blob';
break;
case 'date':
return 'date';
break;
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
/**
* database query result class
*
* @package pxFramework
*
*/
class db_result {
/**
*
*
* @access private
*/
private $_iResId = null;
private $_iConnection = null;
/**
*
*
* @access private
*/

Marius Burkard
committed
public function __construct($iResId, $iConnection) {
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
$this->_iResId = $iResId;
$this->_iConnection = $iConnection;
}
/**
* get count of result rows
*
* Returns the amount of rows in the result set
*
* @access public
* @return int amount of rows
*/
public function rows() {
if(!is_object($this->_iResId)) return 0;
$iRows = mysqli_num_rows($this->_iResId);
if(!$iRows) $iRows = 0;
return $iRows;
}
/**
* Get number of affected rows
*
* Returns the amount of rows affected by the previous query
*
* @access public
* @return int amount of affected rows
*/
public function affected() {
if(!is_object($this->_iConnection)) return 0;
$iRows = mysqli_affected_rows($this->_iConnection);
if(!$iRows) $iRows = 0;
return $iRows;
}
/**
* Frees the result set
*
* @access public
*/
public function free() {
if(!is_object($this->_iResId)) return;
mysqli_free_result($this->_iResId);
return;
}
/**
* Get a result row (associative)
*
* Returns the next row in the result set. To be used in a while loop like while($currow = $result->get()) { do something ... }
*
* @access public
* @return array result row
*/
public function get() {
$aItem = null;
if(is_object($this->_iResId)) {
$aItem = mysqli_fetch_assoc($this->_iResId);
if(!$aItem) $aItem = null;
}
return $aItem;
}
/**
* Get a result row (array with numeric index)
*
* @access public
* @return array result row
*/
public function getAsRow() {
$aItem = null;
if(is_object($this->_iResId)) {
$aItem = mysqli_fetch_row($this->_iResId);
if(!$aItem) $aItem = null;
}
return $aItem;
}
}
/**
* database query result class
*
* emulates a db result set out of an array so you can use array results and db results the same way
*
* @package pxFramework
* @see db_result
*
*
*/
class fakedb_result {
/**
*
*
* @access private
*/
private $aResultData = array();
/**
*
*
* @access private
*/
private $aLimitedData = array();
/**
*
*
* @access private
*/

Marius Burkard
committed
public function __construct($aData) {
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
$this->aResultData = $aData;
$this->aLimitedData = $aData;
reset($this->aLimitedData);
}
/**
* get count of result rows
*
* Returns the amount of rows in the result set
*
* @access public
* @return int amount of rows
*/
// Gibt die Anzahl Zeilen zurück
public function rows() {
return count($this->aLimitedData);
}
/**
* Frees the result set
*
* @access public
*/
// Gibt ein Ergebnisset frei
public function free() {
$this->aResultData = array();
$this->aLimitedData = array();
return;
}
/**
* Get a result row (associative)
*
* Returns the next row in the result set. To be used in a while loop like while($currow = $result->get()) { do something ... }
*
* @access public
* @return array result row
*/
// Gibt eine Ergebniszeile zurück
public function get() {
$aItem = null;
if(!is_array($this->aLimitedData)) return $aItem;
if(list($vKey, $aItem) = each($this->aLimitedData)) {
if(!$aItem) $aItem = null;
}
return $aItem;
}
/**
* Get a result row (array with numeric index)
*
* @access public
* @return array result row
*/
public function getAsRow() {
return $this->get();
}
/**
* Limit the result (like a LIMIT x,y in a SQL query)
*
* @access public
* @param int $iStart offset to start read
* @param int iLength amount of datasets to read
*/
public function limit_result($iStart, $iLength) {
$this->aLimitedData = array_slice($this->aResultData, $iStart, $iLength, true);
}
}