Subversion Repositories ORC

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
7 - 1
package WebDB;
2
  use strict;
3
  use DBI;
4
  my $host_name = "192.168.1.5";
5
  my $db_name = "rollerco_data";
6
  my $dsn = "DBI:mysql:host=$host_name;database=$db_name";
7
 
8
  # Connect to MySQL server, using hardwired name and password
9
  sub connect  {
10
 	  return (DBI->connect ($dsn, "root", "Jopy666!",
11
	  {PrintError => 0, RaiseError => 1}));
12
  }
13
 
14
  # Connect to MySQL server, using name and password from the current
15
  # user's ~/.my.cnf option file. The mysql_read_default_file option,
16
  # when added to the DSN, specifies which option file to read.
17
  sub connect_with_option_file  {
18
	  $dsn .= ";mysql_read_default_file=$ENV{HOME}/.my.cnf";
19
	  return (DBI->connect ($dsn, undef, undef,
20
	  {PrintError => 0, RaiseError => 1}));
21
  }
22
 
23
  sub trim {
24
    my $str = shift;
25
 
26
  	return "" if !defined $str;
27
  	$str =~ s/^\s+//;
28
  	$str =~ s/\s+$//;
29
  	return ($str);
30
  }
31
  1; # return true