EasyDBAccess
view release on metacpan or search on metacpan
EasyDBAccess.pm view on Meta::CPAN
our $_str_func_err_code;
our $_str_func_lookup_err_code;
our $_str_func_is_int;
#===end===
our $_str_func_execute;
our $_str_func_select;
our $_str_func_select_one;
our $_str_func_select_col;
our $_str_func_select_row;
our $_str_func_select_array;
our $_str_new_param_err;
our $_str_new_conn_err;
our $_str_sql_null_err;
our $_str_inline_null_err;
our $_str_no_line;
our $_str_param_err;
our $_str_conn_err;
our $_str_prepare_err;
our $_str_exec_err;
our $_str_dbh_do_err;
our $_str_dbh_prepare_err;
our $_str_dbh_execute_err;
our $_str_dbh_fetchall_arrayref_err;
our $_str_dbh_fetchrow_arrayref_err_a;
our $_str_dbh_fetchrow_arrayref_err_b;
our $_str_dbh_fetchrow_hashref_err_a;
our $_str_dbh_fetchrow_hashref_err_b;
our $_max_conflict;
BEGIN{
#==3.0.3==
$_pkg_name=__PACKAGE__;
#===end===
#===========================================
#=== options
#===if you set $_DEBUG=false then no "die"
$_DEBUG=1;
#===if you set $_SETNAMES=false then won't do set names when connect
$_SETNAMES=1;
#===if you set $_HIDE_CONN_PARAM=true, then won't show connect param when die(protect connection password)
$_HIDE_CONN_PARAM=1;
#============================================
#============================================
#===names
#===name for mysql version
$_name_mysql_ver_3='3.23';
$_name_mysql_ver_41='4.1';
#===use the name of EasyTool if exist
$_name_utf8='utf8';
#============================================
#============================================
$_dbh_attr_default = {PrintError=>0,RaiseError=>0,LongReadLen=>1048576,FetchHashKeyName=>'NAME_lc',AutoCommit=>1};
$_mysql_conn_attrib= ['host','port','database','mysql_client_found_rows','mysql_compression','mysql_connect_timeout','mysql_read_default_file','mysql_read_default_group','mysql_socket','mysql_ssl','mysql_ssl_client_key','mysql_ssl_client_cert','mysql...
$_mysql_error_code_map={
ER_DUP_ENTRY=>1062, #Duplicate entry for key
ER_NO_SUCH_TABLE=>1146, #No such table
ER_PARSE_ERROR=>1064 #SQL string parse error
};
#============================================
$_ONCE=0;#ignore the next function's error
$_str_func_new='new';
$_str_func_id='id';
#==3.0.3==
$_str_func_sid='sid';
$_str_func_die_to_file='die_to_file';
$_str_func_err_str='err_str';
$_str_func_err_code='err_code';
$_str_func_lookup_err_code='_lookup_err_code';
$_str_func_is_int='is_int';
#===end===
$_str_func_execute='execute';
$_str_func_select='select';
$_str_func_select_one='select_one';
$_str_func_select_col='select_col';
$_str_func_select_row='select_row';
$_str_func_select_array='select_array';
$_str_new_param_err='only can accept one or two param';
$_str_new_conn_err='connect to database failed';
$_str_sql_null_err='sql string is null';
$_str_inline_null_err='null in inline param';
$_str_no_line='NO_LINE';
$_str_param_err='PARAM_ERR';
$_str_conn_err='CONN_ERR';
$_str_prepare_err='PREPARE_ERR';
$_str_exec_err='EXEC_ERR';
$_str_dbh_do_err='when call $dbh->do, system return fause';
$_str_dbh_prepare_err='when call $dbh->prepare, system return fause';
$_str_dbh_execute_err='when call $dbh->execute, system return fause';
$_str_dbh_fetchall_arrayref_err='when call $sth->fetchall_arrayref, system return fause, maybe u use select on a none select sql';
$_str_dbh_fetchrow_arrayref_err_a='when call $sth->fetchrow_hashref, system return fause, maybe u use select on a none select sql';
$_str_dbh_fetchrow_arrayref_err_b='when call $dbh->fetchrow_arrayref, system return fause, maybe u try to get one row from a result set with no row in it';
$_str_dbh_fetchrow_hashref_err_a='when call $sth->fetchrow_hashref, system return fause, maybe u use select on a none select sql';
$_str_dbh_fetchrow_hashref_err_b='when call $sth->fetchrow_hashref, system return fause, maybe u try to get one row from a result set with no row in it';
$_max_conflict=10;
}
sub new {
my $class = shift;
my ($param,$option);
my $once=($_ONCE==1)?1:0;
if($once){$_ONCE=0 if $_ONCE==1;};
my $param_count=scalar(@_);
if($param_count==1){
($param)=@_;
}elsif($param_count==2){
($param,$option)=@_;
( run in 1.170 second using v1.01-cache-2.11-cpan-f4a522933cf )