Subversion Repositories php_library

Rev

Rev 47 | Rev 55 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 47 Rev 54
Line 626... Line 626...
626
      we could say implode( ' and ', makeEqualsFromHash($conditions) ) and
626
      we could say implode( ' and ', makeEqualsFromHash($conditions) ) and
627
      get col1=value1 and col2=value2 as the result.
627
      get col1=value1 and col2=value2 as the result.
628
   */
628
   */
629
   function makeEqualsFromHash( $hash, $delimiter='=' ) {
629
   function makeEqualsFromHash( $hash, $delimiter='=' ) {
630
      foreach ( $hash as $key => $value ) {
630
      foreach ( $hash as $key => $value ) {
631
         $hash[$key] = $key . $delimiter . $value;
631
         $hash[$key] = $key . $delimiter . $value ? $value : 'null';
632
      }
632
      }
633
      return $hash;
633
      return $hash;
634
   }
634
   }
635
 
635
 
636
   /*
636
   /*
Line 675... Line 675...
675
         $sql .= ')';
675
         $sql .= ')';
676
         $result = queryDatabaseExtended($sql);
676
         $result = queryDatabaseExtended($sql);
677
         return ($result['insert_id']);
677
         return ($result['insert_id']);
678
      } else { // must be a true update
678
      } else { // must be a true update
679
         $sql = "update $tableName set " . implode(',',makeEqualsFromHash($fieldList) ) . " where $whereClause" ;
679
         $sql = "update $tableName set " . implode(',',makeEqualsFromHash($fieldList) ) . " where $whereClause" ;
680
         //print "\n$sql\n<br>";
-
 
681
         queryDatabaseExtended( $sql );
680
         queryDatabaseExtended( $sql );
682
      }
681
      }
683
   }
682
   }
684
   
683
   
685
   /* function generates a random password. Shamelessly stolen from
684
   /* function generates a random password. Shamelessly stolen from
Line 1214... Line 1213...
1214
                  $sql .= $field . '=' . 'md5(' . makeQuerySafe($_POST[$field . $suffix]) . ')';
1213
                  $sql .= $field . '=' . 'md5(' . makeQuerySafe($_POST[$field . $suffix]) . ')';
1215
               } else {
1214
               } else {
1216
                  $sql .= $field . "=" . makeQuerySafe($_POST[$field . $suffix]);
1215
                  $sql .= $field . "=" . makeQuerySafe($_POST[$field . $suffix]);
1217
               }
1216
               }
1218
            } else { // if no value entered on form, set it to null if possible, otherwise set it to an empty string
1217
            } else { // if no value entered on form, set it to null if possible, otherwise set it to an empty string
1219
               $sql .= $field . "=" . makeQuerySafe($fileName, strtolower($value['default']) == 'null' );
1218
               $sql .= $field . "=" . makeQuerySafe($fileName, $value['default'] === null || strtolower($value['default']) == 'null' );
1220
            }
1219
            }
1221
         }
1220
         }
1222
      }
1221
      }
1223
      // the sql created above needs some stuff added, do that here. We will put the "update" and table name, then
1222
      // the sql created above needs some stuff added, do that here. We will put the "update" and table name, then
1224
      // limit based upon the id passed in.
1223
      // limit based upon the id passed in.