Changeset 758
- Timestamp:
- 01/14/10 15:34:20 (2 years ago)
- Files:
-
- 1 modified
-
trunk/phpbms/modules/api/apiwrapper.php (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/phpbms/modules/api/apiwrapper.php
r754 r758 73 73 * @param string $tabledefuuid The uuid of the tabledefinition that you wish to insert records. 74 74 * @param array $data An array of associative arrays consising of fieldname => value pairs. 75 * @param array $options An associative array of options. Possible options are : 'useUuid', 'dateFormat', 'timeFormat', 'keepDestId' 75 * @param bool $generateUuid Whether to generate a new uuid for the inserted record (and ignore any passed uuid field). 76 * @param bool $keepDestId This option dictates whether or not to keep the destination's id field if "replacing" (via the mysql replace) when there is no id field set. 77 * @param string $dateFormat The format of the dates (if any) in $data. Possible choices are : 'SQL', 'English, US', 'English, UK', or 'Dutch, NL'. If none of these are chosen, it will default to 'SQL'. 78 * @param string $timeFormat The format of the times (if any) in $data. Possible choices are : '24 Hour' or '12 Hour'. If none of these are chosen, it will default to '24 Hour'. 79 * 76 80 * 77 81 * @return array An array of associative arrays of responses for each insert … … 82 86 */ 83 87 84 public function insertRecords($tabledefuuid, $data, $options = NULL) { 85 86 return $this->_runTableCommnad("insert", $tabledefuuid, $data, $options); 88 public function insertRecords($tabledefuuid, $data, $generateUuid = true, $keepDestId = true, $dateFormat = NULL, $timeFormat = NULL) { 89 90 if($generateUuid !== true) 91 $generateUuid = false; 92 93 if($keepDestId !== true) 94 $keepDestId = false; 95 96 switch($dateFormat){ 97 98 case "SQL": 99 case "English, US": 100 case "English, UK": 101 case "Dutch, NL": 102 break; 103 104 default: 105 $dateFormat = "SQL"; 106 break; 107 108 }//end switch 109 110 switch($timeFormat){ 111 112 case "24 Hour": 113 case "12 Hour": 114 break; 115 116 default: 117 $timeFormat = "24 Hour"; 118 break; 119 120 }//end switch 121 122 $options = array( 123 "useUuid" => $generateUuid, 124 "dateFormat" => $dateFormat, 125 "timeFormat" => $timeFormat, 126 "keepDestId" => $keepDestId 127 ); 128 129 return $this->_runTableCommnad("insert", $tabledefuuid, $data, $options); 87 130 88 131 }//end function … … 94 137 * @param string $tabledefuuid The uuid of the tabledefinition that you wish to update records. 95 138 * @param array $data An array of associative arrays consising of fieldname => value pairs. 96 * @param array $options An associative array of options. Possible options are : 'useUuid', 'dateFormat', 'timeFormat', 'keepDestId' 139 * @param bool $useUuid Whether to use the id (false) or the uuid (true) in the update whereclause. 140 * @param string $dateFormat The format of the dates (if any) in $data. Possible choices are : 'SQL', 'English, US', 'English, UK', or 'Dutch, NL'. If none of these are chosen, it will default to 'SQL'. 141 * @param string $timeFormat The format of the times (if any) in $data. Possible choices are : '24 Hour' or '12 Hour'. If none of these are chosen, it will default to '24 Hour'. 97 142 * 98 143 * @return array An array of associative arrays of responses for each update … … 102 147 */ 103 148 104 public function updateRecords($tabledefuuid, $data, $options = NULL) { 149 public function updateRecords($tabledefuuid, $data, $useUuid = true, $dateFormat = NULL, $timeFormat = NULL) { 150 151 if($useUuid !== true) 152 $useUuid = false; 153 154 switch($dateFormat){ 155 156 case "SQL": 157 case "English, US": 158 case "English, UK": 159 case "Dutch, NL": 160 break; 161 162 default: 163 $dateFormat = "SQL"; 164 break; 165 166 }//end switch 167 168 switch($timeFormat){ 169 170 case "24 Hour": 171 case "12 Hour": 172 break; 173 174 default: 175 $timeFormat = "24 Hour"; 176 break; 177 178 }//end switch 179 180 $options = array( 181 "useUuid" => $useUuid, 182 "dateFormat" => $dateFormat, 183 "timeFormat" => $timeFormat 184 ); 105 185 106 186 return $this->_runTableCommnad("update", $tabledefuuid, $data, $options); … … 113 193 * 114 194 * @param string $tabledefuuid The uuid of the tabledefinition that you wish to get records. 115 * @param array $data An array of associative arrays of table uuids (or integer ids if useUuid option is set to false). The key=>value format is 'uuid'=>'{the actual uuid}'116 * @param array $options An associative array of options. Possible options are : 'useUuid', 'dateFormat', 'timeFormat'195 * @param mixed $ids Either an array uuids (or ids if $useUuid = false), or an individual uuid (or id). 196 * @param bool $useUuid Whether the data is an array of uuids or ids 117 197 * 118 198 * @return array An array of associative arrays of responses for each get … … 123 203 */ 124 204 125 public function getRecords($tabledefuuid, $data, $options = NULL) { 205 public function getRecords($tabledefuuid, $ids, $useUuid = true) { 206 207 if($useUuid !== true) 208 $useUuid = false; 209 210 if($useUuid) 211 $keyName = "uuid"; 212 else 213 $keyName = "id"; 214 215 if(!is_array($ids)) 216 $ids = array($ids); 217 218 $data = array(); 219 foreach($ids as $id){ 220 221 if($useUuid) 222 $id = (string)$id; 223 else 224 $id = (int)$id; 225 $data[][$keyName] = $id; 226 227 }//end foreach 228 229 $options = array( 230 "useUuid" => $useUuid 231 ); 126 232 127 233 return $this->_runTableCommnad("get", $tabledefuuid, $data, $options); … … 133 239 * function deleteRecords 134 240 * 135 * @param string $tabledefuuid The uuid of the tabledefinition that you wish to delete records.136 * @param array $data An array associative arrays with the key 'uuid' (or 'id' if useUuid option is set to false) and the relevant value.137 * @param array $options An associative array of options. Possible options are : 'useUuid'241 * @param string $tabledefuuid The uuid of the tabledefinition that you wish to delete (or inactivate, depending upon the tabledef) records. 242 * @param mixed $ids Either an array uuids (or ids if $useUuid is false), or an individual uuid (or id). 243 * @param bool $useUuid Whether the data is an array of uuids or ids. 138 244 * 139 245 * @return array An array of associative arrays of responses for each delete … … 143 249 */ 144 250 145 public function deleteRecords($tabledefuuid, $records, $options = NULL) { 146 147 return $this->_runTableCommnad("delete", $tabledefuuid, $records, $options); 251 public function deleteRecords($tabledefuuid, $ids, $useUuid = true) { 252 253 if($useUuid !== true) 254 $useUuid = false; 255 256 if($useUuid) 257 $keyName = "uuid"; 258 else 259 $keyName = "id"; 260 261 if(!is_array($ids)) 262 $ids = array($ids); 263 264 $data = array(); 265 foreach($ids as $id){ 266 267 if($useUuid) 268 $id = (string)$id; 269 else 270 $id = (int)$id; 271 $data[][$keyName] = $id; 272 273 }//end foreach 274 275 $options = array( 276 "useUuid" => $useUuid 277 ); 278 279 return $this->_runTableCommnad("delete", $tabledefuuid, $data, $options); 148 280 149 281 }//end function … … 204 336 * function searchClientByEmail 205 337 * @param string $email The email to be searched for 206 * @param array $options An associative array of options. Possible options are : 'useUuid'338 * @param bool $useUuid Whether to return uuids or ids. 207 339 * 208 340 * @return array An associative array response for the get … … 212 344 */ 213 345 214 public function searchClientByEmail($email, $ options = NULL) {346 public function searchClientByEmail($email, $useUuid = true) { 215 347 216 348 $method = "api_searchByEmail"; 217 349 $tabledefuuid = "tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083"; 218 350 $data["email"] = (string)$email; 351 352 if($useUuid !== true) 353 $useUuid = false; 354 355 $options = array( 356 "useUuid" => $useUuid 357 ); 219 358 220 359 $response = $this->runApiMethod($method, $tabledefuuid, $data, $options); … … 232 371 * @param name $lastname The last name to search for in the client's table 233 372 * @param name $postalcode The postal code to search for in the client's table 234 * @param array $options An associative array of options. Possible options are : 'useUuid'373 * @param bool $useUuid Whether to return uuids or ids. 235 374 * 236 375 * @return array An associative array response for the get … … 240 379 */ 241 380 242 public function searchClientByNameAndPostalcode($firstname, $lastname, $postalcode, $ options = NULL) {381 public function searchClientByNameAndPostalcode($firstname, $lastname, $postalcode, $useUuid = true) { 243 382 244 383 $method = "api_searchByNameAndPostalcode"; … … 248 387 $data["postalcode"] = (string)$postalcode; 249 388 389 if($useUuid !== true) 390 $useUuid = false; 391 392 $options = array( 393 "useUuid" => $useUuid 394 ); 395 250 396 $response = $this->runApiMethod($method, $tabledefuuid, $data, $options); 251 397 … … 262 408 * @param string $username The username to search for in the client's table 263 409 * @param string $password The password to search for in the client's table 264 * @param array $options An associative array of options. Possible options are : 'useUuid'410 * @param bool $useUuid Whether to return uuids or ids. 265 411 * 266 412 * @return array An associative array response for the get … … 270 416 */ 271 417 272 public function searchClientByUsernameAndPassword($username, $password, $ options = NULL) {418 public function searchClientByUsernameAndPassword($username, $password, $useUuid = true) { 273 419 274 420 $method = "api_searchByUsernameAndPassword"; … … 276 422 $data["username"] = (string)$username; 277 423 $data["password"] = (string)$password; 424 425 if($useUuid !== true) 426 $useUuid = false; 427 428 $options = array( 429 "useUuid" => $useUuid 430 ); 278 431 279 432 $response = $this->runApiMethod($method, $tabledefuuid, $data, $options); … … 293 446 * @param string $startdate The sql encoded DATETIME lower range of creation dates. 294 447 * @param string $enddate The sql encoded DATETIME upper range of creation dates. 295 * @param array $options An associative array of options. Possible options are : 'useUuid'448 * @param bool $useUuid Whether to return uuids or ids. 296 449 * 297 450 * @return array An associative array response for the get … … 301 454 */ 302 455 303 function searchSalesOrdersByClientUuid($clientuuid, $ordertype = NULL, $startdate = NULL, $enddate = NULL, $ options = NULL) {456 function searchSalesOrdersByClientUuid($clientuuid, $ordertype = NULL, $startdate = NULL, $enddate = NULL, $useUuid = true) { 304 457 305 458 $method = "api_searchByClientUuid"; … … 312 465 if($enddate !== NULL) 313 466 $data["enddate"] = $enddate; 467 468 if($useUuid !== true) 469 $useUuid = false; 470 471 $options = array( 472 "useUuid" => $useUuid 473 ); 314 474 315 475 $response = $this->runApiMethod($method, $tabledefuuid, $data, $options);