Changeset 3223 for trunk/archive/psdb/psDB.c
- Timestamp:
- Feb 14, 2005, 9:28:50 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/archive/psdb/psDB.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/archive/psdb/psDB.c
r3222 r3223 8 8 * @author Joshua Hoblitt 9 9 * 10 * @version $Revision: 1.2 4$ $Name: not supported by cvs2svn $11 * @date $Date: 2005-02-15 07:2 7:02$10 * @version $Revision: 1.25 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2005-02-15 07:28:50 $ 12 12 * 13 13 * Copyright 2005 Joshua Hoblitt, University of Hawaii … … 39 39 static char *psDBGenerateInsertRowSQL(const char *tableName, psMetadata *row); 40 40 static char *psDBGenerateUpdateRowSQL(const char *tableName, psMetadata *where, psMetadata *values); 41 static char *psDBGenerateDeleteRowSQL(const char *tableName, psMetadata *where); 41 42 static char *psDBGenerateWhereSQL(psMetadata *where); 42 43 static char *psDBGenerateSetSQL(psMetadata *set); … … 638 639 psU32 paramCount; // number of placeholders in query 639 640 MYSQL_BIND *bind; // field values to insert 640 psU64 rowsAffected; 641 psU64 rowsAffected; // number of rows affected by query 641 642 642 643 query = psDBGenerateUpdateRowSQL(tableName, where, values); … … 716 717 } 717 718 719 psS64 psDBDeleteRows(psDB *dbh, const char *tableName, psMetadata *where) 720 { 721 char *query; 722 723 query = psDBGenerateDeleteRowSQL(tableName, where); 724 if (!query) { 725 return -1; 726 } 727 728 if (!psDBRunQuery(dbh, query)) { 729 psFree(query); 730 731 return -1; 732 } 733 734 psFree(query); 735 736 if (!where) { 737 // we truncated the table so mysql_affected_rows() won't work 738 739 return 1; 740 } 741 742 return (psS64)mysql_affected_rows(dbh->mysql); 743 } 718 744 719 745 // database utility functions … … 967 993 psFree(setSQL); 968 994 psFree(whereSQL); 995 996 return query; 997 } 998 999 static char *psDBGenerateDeleteRowSQL(const char *tableName, psMetadata *where) 1000 { 1001 char *query = NULL; 1002 char *whereSQL; 1003 1004 // delete all rows if where is NULL 1005 if (!where) { 1006 psStringAppend(&query, "TRUNCATE TABLE %s", tableName); 1007 1008 return query; 1009 } 1010 1011 whereSQL = psDBGenerateWhereSQL(where); 1012 if (!whereSQL) { 1013 return NULL; 1014 } 1015 1016 psStringAppend(&query, "DELETE FROM %s %s", tableName, whereSQL); 969 1017 970 1018 return query;
Note:
See TracChangeset
for help on using the changeset viewer.
