MySQL-ORM

 view release on metacpan or  search on metacpan

t/testlib.pl  view on Meta::CPAN

use Modern::Perl;
use Carp;
use String::Util ':all';
use DBI;
use File::Which;
use File::Path 'remove_tree';

use constant DBNAME => 'testmysqlorm';
use constant DBNAME_FK => 'testmysqlorm_fk';

my $MysqlHost = "localhost";

sub get_dbh {

	my $dbh;

	eval {
		$dbh = DBI->connect( 'dbi:mysql:host=localhost',
			'root', undef, { RaiseError => 1, PrintError => 0 } );
	};

	if ($@) {
	    $MysqlHost = "127.0.0.1";
		$dbh = DBI->connect( 'dbi:mysql:host=127.0.0.1',
			'root', undef, { RaiseError => 1, PrintError => 0 } );
	};

	eval { $dbh->do( "use " . DBNAME ); };

	return $dbh;
}

sub check_connection {

	eval { get_dbh(); };
	if ($@) {
		print STDERR $@ . "\n";
		return 0;
	}

	return 1;
}

sub remove_tmp {

	if ( !$ENV{SKIP_REMOVE_TREE} ) {
		remove_tree('tmp');
		verbose("tmp cleaned");
	}
}

sub mysql_binary_exists {

	if ( which('mysql') ) {
		return 1;
	}

	return 0;
}

sub get_mysql_cmdline {



( run in 0.652 second using v1.01-cache-2.11-cpan-39bf76dae61 )