Subversion Repositories phpLibraryV2

Rev

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

Rev 39 Rev 40
Line 286... Line 286...
286
      public function run () {
286
      public function run () {
287
         return $this->doSQL( );
287
         return $this->doSQL( );
288
      }
288
      }
289
      
289
      
290
      /**
290
      /**
-
 
291
       * Simple function returns last inserted id on succes, false on 
-
 
292
       * failure
-
 
293
       * 
-
 
294
       * @params string $query An insert query to execute
-
 
295
       * @return integer The insert id from this insert, if applicable
-
 
296
       */
-
 
297
      
-
 
298
      public function insert( $query ) {
-
 
299
         return $this->query( $query ) ? $this->insert_id : false;
-
 
300
      }
-
 
301
         
-
 
302
      
-
 
303
      /**
291
       * returns an array of the first column for each row returned from query
304
       * returns an array of the first column for each row returned from query
292
       * 
305
       * 
293
       * The query is run, then for each row returns, the first column
306
       * The query is run, then for each row returns, the first column
294
       * is added to $return (an array). $return is then returned.
307
       * is added to $return (an array). $return is then returned.
295
       * 
308
       * 
Line 510... Line 523...
510
      /**
523
      /**
511
       * Creates an insert query from $fields
524
       * Creates an insert query from $fields
512
       * 
525
       * 
513
       */
526
       */
514
       public function insertQuery( $tablename, $fields ) {
527
       public function insertQuery( $tablename, $fields ) {
515
          print "<pre>insertQuery\n\ntable\n$tablename\n</pre>";
528
          //print "<pre>insertQuery\n\ntable\n$tablename\n</pre>";
516
          print "<pre>fields\n" . print_r( $fields, true ) . "\n</pre>"; die;
529
          //print "<pre>fields\n" . print_r( $fields, true ) . "\n</pre>"; die;
517
          $query = "insert into $tablename (" . implode( ',',array_keys($fields) );
530
          $query = "insert into $tablename (" . implode( ',',array_keys($fields) );
518
          $query .= " values (" . implode( ',', array_map( array($this, 'real_escape_string'), array_values( $fields ) ) );
531
          $query .= ") values (" . implode( ',', array_map( array($this, 'my_escape_string'), array_values( $fields ) ) );
519
          return "$query)";
532
          return "$query)";
520
       } // insertQuery
533
       } // insertQuery
521
            
534
            
522
 
535
 
523
   } // class DBQuery
536
   } // class DBQuery