Subversion Repositories phpLibraryV2

Rev

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

Rev 29 Rev 34
Line 282... Line 282...
282
      }  // function doSQL
282
      }  // function doSQL
283
      
283
      
284
      public function run () {
284
      public function run () {
285
         return $this->doSQL( );
285
         return $this->doSQL( );
286
      }
286
      }
-
 
287
      
-
 
288
      /**
-
 
289
       * returns an array of the first column for each row returned from query
-
 
290
       * 
-
 
291
       * The query is run, then for each row returns, the first column
-
 
292
       * is added to $return (an array). $return is then returned.
-
 
293
       * 
-
 
294
       * Used to do things like get an array of keyfields, or something
-
 
295
       * else.
-
 
296
       * 
-
 
297
       * @param string $query Query to run
-
 
298
       * @returns string[] Array of values
-
 
299
       */
-
 
300
      public function columnToArray( $query ) {
-
 
301
         $return = array();
-
 
302
         $result = $this->doSQL( $query );
-
 
303
         foreach ( $result['returnData'] as $row ) {
-
 
304
            $return[] = $row['id'];
-
 
305
         }
-
 
306
         return $return;
-
 
307
      }
287
 
308
 
288
      /*
309
      /*
289
       * function will return one and only one row, NOT as an array of array
310
       * function will return one and only one row, NOT as an array of array
290
       * but as a single row array
311
       * but as a single row array
291
       * if more than one row is returned by query, error is set and function
312
       * if more than one row is returned by query, error is set and function
Line 309... Line 330...
309
         
330
         
310
 
331
 
311
      // function returns the first column of the first row of data returned from query
332
      // function returns the first column of the first row of data returned from query
312
      // or null no value returned
333
      // or null no value returned
313
      public function getOneDBValue( $sql = null ) {
334
      public function getOneDBValue( $sql = null ) {
-
 
335
         //print '<pre>' . $sql . '</pre>';
314
         if ( isset( $sql ) )
336
         if ( isset( $sql ) )
315
            $this->parameters[ 'query' ] = $sql;
337
            $this->parameters[ 'query' ] = $sql;
316
         $save = $this->parameters['returntype'];
338
         $save = $this->parameters['returntype'];
317
         $this->parameters['returntype'] = 'array';
339
         $this->parameters['returntype'] = 'array';
318
         $this->run();
340
         $this->run();