Subversion Repositories phpLibraryV2

Rev

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

Rev 43 Rev 44
Line 290... Line 290...
290
      public function run () {
290
      public function run () {
291
         return $this->doSQL( );
291
         return $this->doSQL( );
292
      }
292
      }
293
      
293
      
294
      /**
294
      /**
295
       * Simple function returns last inserted id on succes, false on 
295
       * Simple function returns last inserted id on success, false on 
296
       * failure
296
       * failure
297
       * 
297
       * 
298
       * @params string $query An insert query to execute
298
       * @params string $query An insert query to execute
299
       * @return integer The insert id from this insert, if applicable
299
       * @return integer The insert id from this insert, if applicable
300
       */
300
       */
301
      
301
      
302
      public function insert( $query ) {
302
      public function insert( $query ) {
303
         return $this->query( $query ) ? $this->insert_id : false;
303
         return $this->query( $query ) ? $this->insert_id : false;
304
      }
304
      }
305
         
305
         
-
 
306
       /**
-
 
307
        * A query with at least two columns in the result is converted to a 
-
 
308
        * key => value array. The first column is the key, the second is the value
-
 
309
        * All other columns are ignored
-
 
310
        */
-
 
311
       
-
 
312
       public function queryToKeyedArray ( $query ) {
-
 
313
          $return = array();
-
 
314
         $result = $this->doSQL( $query, array( 'returnType' => 'array' ) );
-
 
315
         foreach ( $result['returnData'] as $row ) {
-
 
316
            $return[$row[0]] = $row[1];
-
 
317
         }
-
 
318
         return $return;
-
 
319
      }
-
 
320
 
-
 
321
 
306
      
322
      
307
      /**
323
      /**
308
       * returns an array of the first column for each row returned from query
324
       * returns an array of the first column for each row returned from query
309
       * 
325
       * 
310
       * The query is run, then for each row returns, the first column
326
       * The query is run, then for each row returns, the first column
Line 535... Line 551...
535
          //print "<pre>fields\n" . print_r( $fields, true ) . "\n</pre>"; die;
551
          //print "<pre>fields\n" . print_r( $fields, true ) . "\n</pre>"; die;
536
          $query = "insert into $tablename (" . implode( ',',array_keys($fields) );
552
          $query = "insert into $tablename (" . implode( ',',array_keys($fields) );
537
          $query .= ") values (" . implode( ',', array_map( array($this, 'my_escape_string'), array_values( $fields ) ) );
553
          $query .= ") values (" . implode( ',', array_map( array($this, 'my_escape_string'), array_values( $fields ) ) );
538
          return "$query)";
554
          return "$query)";
539
       } // insertQuery
555
       } // insertQuery
-
 
556
       
-
 
557
 
540
            
558
            
541
 
559
 
542
   } // class DBQuery
560
   } // class DBQuery
543
 
561
 
544
/*
562
/*