Subversion Repositories php_users

Rev

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

Rev 17 Rev 18
Line 233... Line 233...
233
      public function getPassword( $username ) {
233
      public function getPassword( $username ) {
234
         return $this->getARecord( array('login' => $username,'enabled' => 1), array('pass' => 1 ) );
234
         return $this->getARecord( array('login' => $username,'enabled' => 1), array('pass' => 1 ) );
235
      }
235
      }
236
      
236
      
237
      /**
237
      /**
238
       * Gets the entire record for a user
-
 
239
       * 
-
 
240
       * NOTE: this does not actually get all columns. getARecord only gets
-
 
241
       * the columns defined in $configuration
-
 
242
       * 
-
 
243
       * @param string $username the value of the login field to find
-
 
244
       * 
-
 
245
       * @return string[] fieldname=>value array of found record
-
 
246
       */
-
 
247
      public function getRecord ( $username ) {
-
 
248
         return $this->getARecord( array( 'login' => $username ) );
-
 
249
      }
-
 
250
      
-
 
251
      /**
-
 
252
       * Make the database connection
238
       * Make the database connection
253
       * 
239
       * 
254
       * @param string[] $parameters Parameters for makeing the connection
240
       * @param string[] $parameters Parameters for makeing the connection
255
       * @return mysqli|false
241
       * @return mysqli|false
256
       */
242
       */
Line 374... Line 360...
374
               }
360
               }
375
               $query = 'insert into ' . $this->configuration['tables']['users']['table'] . 
361
               $query = 'insert into ' . $this->configuration['tables']['users']['table'] . 
376
                  '(' . implode( ',', $columns ) . ') values (' .
362
                  '(' . implode( ',', $columns ) . ') values (' .
377
                  implode( ',', $values ) . ')';
363
                  implode( ',', $values ) . ')';
378
            }
364
            }
379
            return $this->doSQL( $query );
365
            return $this->doSQL( $query, 'update' );
380
         }
366
         }
381
      } // update
367
      } // update
382
      
368
      
383
      /**
369
      /**
384
       * retrieves all users from the database
370
       * retrieves all users from the database
Line 406... Line 392...
406
       * Created for testing and debugging, if the second parameter is 
392
       * Created for testing and debugging, if the second parameter is 
407
       * true, will NOT execute the query, but will instead display the 
393
       * true, will NOT execute the query, but will instead display the 
408
       * query passed.
394
       * query passed.
409
       * 
395
       * 
410
       * @parameter string $query SQL Query to execute
396
       * @parameter string $query SQL Query to execute
411
       * @parameter boolean $testing If set to true, displays query instead of executing it
397
       * @parameter string $comment if not empty, writes comment and query to a file
412
       * 
398
       * 
413
       * @returns mysqli_result
399
       * @returns mysqli_result
414
       */
400
       */
415
      protected function doSQL( $query, $testing = false ) {
401
      protected function doSQL( $query, $comment = '' ) {
416
         
402
         if ( $comment ) {
417
         $handle = fopen( '/tmp/log.sql', 'a' );
403
            $handle = fopen( '/tmp/log.sql', 'a' );
418
         fwrite( $handle, "$query\n" );
404
            fwrite( $handle, "$comment\n$query\n" );
419
         fclose( $handle );
405
            fclose( $handle );
420
         
406
         }
421
         mysqli_report( MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT );
407
         mysqli_report( MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT );
422
         $result = $this->dbConnection->query( $query );
408
         $result = $this->dbConnection->query( $query );
423
         return $result;
409
         return $result;
424
      }
410
      }
425
      
411