classes.other/PSM.php
/*Makes the update function easier to use.*/
Makes the update function easier to use.
Makes the update function easier to use .
public function update($table, $updates, $where, $debug = false)
          {
              $statement = "UPDATE {$table} SET ";
              $cols = array_keys($updates);
              $vals = array_values($updates);
              foreach ($cols as $index => $col) { $cols[$index] = "$col = ?"; }
              $statement .= implode(', ', $cols);
              $where_parts = explode(' = ',$where);
              $statement .= " WHERE {$where_parts[0]} = ?";
              array_push($vals, $where_parts[1]);
              $q = $this->cquery( $statement, $vals );
              if ($debug) { $this->Display($vals); echo $statement; }
          }
public function update ( $ table , $ updates , $ where , $ debug = false ) { $ statement = " UPDATE  { $ table }  SET  " ; $ cols = array_keys ( $ updates ) ; $ vals = array_values ( $ updates ) ; foreach ( $ cols as $ index => $ col ) { $ cols [ $ index ] = " $ col  = ? " ; } $ statement .= implode ( ', ' , $ cols ) ; $ where_parts = explode ( ' = ' , $ where ) ; $ statement .= "  WHERE  { $ where_parts [ 0 ] }  = ? " ; array_push ( $ vals , $ where_parts [ 1 ] ) ; $ q = $ this -> cquery ( $ statement , $ vals ) ; if ( $ debug ) { $ this -> Display ( $ vals ) ; echo $ statement ; } }
Makes the update function easier to use.
Makes the update function easier to use .
// Build the start of the query. // Getting the columns and values. // Add ' = ?' to each of the columns. // Splits to create the sides of the where statement. // Performing the query. // Debug manager.