Subversion Repositories CoffeeCatalog

Rev

Rev 3 | Details | Compare with Previous | Last modification | View Log | RSS feed

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