Changeset 4297 for trunk/psLib/src/db
- Timestamp:
- Jun 17, 2005, 11:33:46 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/db/psDB.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/db/psDB.c
r4279 r4297 12 12 * @author Joshua Hoblitt 13 13 * 14 * @version $Revision: 1.2 6$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-06-1 6 01:48:18$14 * @version $Revision: 1.27 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2005-06-17 21:33:46 $ 16 16 * 17 17 * Copyright 2005 Joshua Hoblitt, University of Hawaii … … 513 513 psArray *rowSet; // psArray of row to insert 514 514 515 // Check for null row 516 if(row == NULL) { 517 psError(PS_ERR_UNKNOWN,true,PS_ERRORTEXT_psDB_INSERT_ROW_FAIL); 518 return false; 519 } 520 521 // Create array to store single row 515 522 rowSet = psArrayAlloc(1); 516 523 rowSet->n = 0; 517 524 psArrayAdd(rowSet, 0, row); 518 525 526 // Execute function to insert rows 519 527 if (!psDBInsertRows(dbh, tableName, rowSet)) { 520 psError(PS_ERR_UNKNOWN, false, "Insert failed."); 521 528 psError(PS_ERR_UNKNOWN, false, PS_ERRORTEXT_psDB_INSERT_ROW_FAIL); 522 529 psFree(rowSet); 523 524 530 return false; 525 531 } … … 539 545 psU64 j; // row index 540 546 547 // Verify database connections is set up 548 if(dbh == NULL) { 549 psError(PS_ERR_UNEXPECTED_NULL,true,PS_ERRORTEXT_psDB_INVALID_PSDB); 550 return false; 551 } 552 541 553 // we are assuming that all rows in the set have an identical with reguard 542 554 // to field count and type 543 555 row = rowSet->data[0]; 544 556 557 // Generate SQL query string 545 558 query = psDBGenerateInsertRowSQL(tableName, row); 546 559 if (!query) { 547 psError(PS_ERR_UNEXPECTED_NULL, false, "Query generation failed.");548 549 return NULL;550 } 551 560 psError(PS_ERR_UNEXPECTED_NULL, false, PS_ERRORTEXT_psDB_QUERY_GEN_FAIL); 561 return false; 562 } 563 564 // Prepare SQL statement 552 565 stmt = mysql_stmt_init(dbh->mysql); 553 566 if (!stmt) { 554 567 psAbort(__func__, "mysql_stmt_init(), out of memory."); 555 568 } 556 557 569 if (mysql_stmt_prepare(stmt, query, (unsigned long)strlen(query))) { 558 570 psError(PS_ERR_UNKNOWN, true, "Failed to prepare query. Error: %s", mysql_stmt_error(stmt)); 559 560 571 mysql_stmt_close(stmt); 561 572 psFree(query); 562 563 573 return false; 564 574 }
Note:
See TracChangeset
for help on using the changeset viewer.
