[Bio] / FigKernelPackages / DBrtns.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/DBrtns.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.10, Sun Feb 27 14:05:58 2005 UTC revision 1.12, Fri Apr 8 08:32:10 2005 UTC
# Line 69  Line 69 
69    
70      $dbh  = $self->{_dbh};      $dbh  = $self->{_dbh};
71    
72      if ($sql =~ /^select/i)      if ($sql =~ /^\s*select/i)
73      {      {
74          my $ok = eval {          my $ok = eval {
75              $tmp = $dbh->selectall_arrayref($sql, undef, @bind_values);              $tmp = $dbh->selectall_arrayref($sql, undef, @bind_values);
# Line 244  Line 244 
244      }      }
245  }  }
246    
247    =pod
248    
249    =head1 get_inserted_id
250    
251    Return the last ID of a row inserted into an autonumber/serial-containing table.
252    
253    =cut
254    
255    sub get_inserted_id
256    {
257        my($self, $table, $sth) = @_;
258        if ($self->{_dbms} eq "Pg")
259        {
260            my $oid = $sth->{pg_oid_status};
261            my $ret = $self->SQL("select id from $table where oid = ?", undef, $oid);
262            return $ret->[0]->[0];
263        }
264        elsif ($self->{_dbms} eq "mysql")
265        {
266            my $id = $self->{_dbh}->{mysql_insertid};
267            # print "mysql got $id\n";
268            return $id;
269        }
270    }
271    
272    
273  #  #
274  # Following are database administration routines. They create an instance of a ServerAdmin class  # Following are database administration routines. They create an instance of a ServerAdmin class
275  # for the appropriate server type (in order to eliminate the if mysql / if pg / etc stuff).  # for the appropriate server type (in order to eliminate the if mysql / if pg / etc stuff).

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.12

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3