/********************************************************************** * ezSQL initialisation for mySQL */ // Include ezSQL core include_once "../shared/ez_sql_core.php"; // Include ezSQL database specific component include_once "ez_sql_mysql.php"; // Initialise database object and establish a connection // at the same time - db_user / db_password / db_name / db_host $db = new ezSQL_mysql('db_user', 'db_password', 'db_name', 'db_host'); /********************************************************************** * ezSQL demo for mySQL database */ // Demo of getting a single variable from the db // (and using abstracted function sysdate) $current_time = $db->get_var("SELECT " . $db->sysdate()); print "ezSQL demo for mySQL database run @ {$current_time}"; // Print out last query and results.. $db->debug(); // Get list of tables from current database.. $my_tables = $db->get_results("SHOW TABLES", ARRAY_N); // Print out last query and results.. $db->debug(); // Loop through each row of results.. foreach ($my_tables as $table) { // Get results of DESC table.. $db->get_results("DESC {$table['0']}"); // Print out last query and results.. $db->debug(); }
// Cache expiry $SKTDB->cache_timeout = 24; // Note: this is hours // Specify a cache dir. Path is taken from calling script $SKTDB->cache_dir = 'ezsql_cache'; // (1. You must create this dir. first!) // (2. Might need to do chmod 775) // Global override setting to turn disc caching off // (but not on) $SKTDB->use_disk_cache = true; // By wrapping up queries you can ensure that the default // is NOT to cache unless specified $SKTDB->cache_queries = true; // At last.. a query! $SKTDB->get_results("SHOW TABLES"); $SKTDB->debug(); // Select * from use $SKTDB->get_results("SELECT * FROM v1_content"); $SKTDB->debug(); // This ensures only the above querys are cached $SKTDB->cache_queries = false; // This query is NOT cached $SKTDB->get_results("SELECT * FROM v1_content LIMIT 0,1"); $SKTDB->debug(); /* Of course, if you want to cache EVERYTHING just do.. $SKTDB = new ezSQL_mysql('db_user', 'db_pass', 'db_name'); $SKTDB->use_disk_cache = true; $SKTDB->cache_queries = true;