)
{db :: get_instance () - gt; get_last_id ($ db_alias);
} static function affected_rows ($ db_alias= master )
{db :: get_instance () - gt; get_affected_rows ($ db_alias);
} static function explain ($ query)
{db :: rows ( EXPLAIN . $ query, array (), __ );
} function connect ($ db_alias= master )
{(isset ($ this- gt; db_links [$ db_alias]) amp; amp; $ this- gt; db_links [$ db_alias])
{$ this- gt; db_links [$ db_alias];
} (config :: get ( debug_mode ))
{
$ start_time=microtime (true);
}
$ d=$ this- gt; db_params [$ db_alias];
$ this- gt; db_links [$ db_alias]=mysql_connect ($ d [ host ], $ d [ user ], $ d [ pass ]); ( config :: get ( debug_mode ))
{
$ span=microtime (true) - $ start_time; :: add ( db raquo ;, array ( timespan = gt; $ span, alias = gt; connect to . $ db_alias, operation = gt; connect ));
} :: exec ( SET NAMES utf8 raquo ;, array (), $ db_alias); ($ this- gt; db_links [$ db_alias])
{$ this- gt; db_links [$ db_alias];
} :: err ( Connection failed to . $ db_alias. n . mysql_error ()); false;
} function prepare ($ statement, $ db_alias= master )
{
$ db=db :: get_instance (); $ db- gt; query_prepare ($ statement, $ db_alias);
} function query_prepare ($ statement, $ db_alias= master )
{
$ this- gt; error_code=0;
$ this- gt; error_info= raquo ;;
$ this- gt; counter ++; (! isset ($ this- gt; db_params [$ db_alias]))
{
$ db_alias= master raquo ;;
}
$ db_handle=$ this- gt; connect ($ db_alias); (! $ db_handle)
{false;
} new sql_statement ($ this, $ statement, $ db_alias, $ db_handle);
} function execute ($ statement, $ params=array (), $ db_alias= master )
{
$ stmt=$ this- gt; query_prepare ($ statement, $ db_alias); ($ params as $ key= gt; $ value)
{(is_int ($ value))
{
$ stmt- gt; bind ($ key, $ value, SQL_PARAM_INT);
} (is_array ($ value))
{(! count ($ value))
{new Exception ( Array must have at least one element );
} (is_int ($ value [0]))
{
$ stmt- gt; bind ($ key, $ value, SQL_PARAM_ARRAY_INT);
}
{
$ value [0]=(string) $ value [0];
$ stmt- gt; bind ($ key, $ value, SQL_PARAM_ARRAY_STR);
}
}
{
$ stmt- gt; bind ($ key, $ value, SQL_PARAM_STR);
}
} $ stmt- gt; execute ();
} function get_row ($ statement, $ params=array (), $ db_alias= master )
{
$ handle=$ this- gt; execute ($ statement, $ params, $ db_alias); mysql_fetch_assoc ($ handle);
} function get_rows ($ statement, $ params=array (), $ key= id raquo ;, $ db_alias= master )
{
$ handle=$ this- gt; execute ($ statement, $ params, $ db_alias);
$ res=array (); ($ a=mysql_fetch_assoc ($ handle))
{($ key amp; amp; isset ($ a [$ key]) amp; amp; $ a [$ key])
{
$ res [$ a [$ key]]=$ a;
}
{
$ res []=$ a;
}
} $ res;
} function get_cols ($ statement, $ params=array (), $ db_alias= master )
{
$ handle=$ this- gt; execute ($ statement, $ params, $ db_alias);
$ res=array (); ($ a=mysql_fetch_row ($ handle))
{(array_key_exists (0, $ a) amp; amp; array_key_exists (1, $ a))
{
$ res [$ a [0]]=$ a [1];
} (isset ($ a [0]))
{