. ======================================================================*/ /** * A number of functions to make PHP4/5 compatibility easier. */ if (version_compare(phpversion(), '5.0') < 0) { /** * Define a clone function so clone($obj) works in every version. */ eval('function clone($object) { return $object; }'); /** * file_put_contents not available in php4- */ function file_put_contents($filename, $data) { //[int $flags[, resource $context]] if (is_array($data)) $data = implode('', $data); $total = $datalen = strlen($data); if (($fp = fopen($filename, 'wb')) !== false) { while ($datalen !== 0) { if (($written = fwrite($fp, $data)) === false) { fclose($fp); return false; } $datalen -= $written; $data = substr($data, $written); } fclose($fp); return $total; } return false; } } /** * usleep is not available on windows before PHP5. */ if (!function_exists('usleep')) { function usleep($usec) { socket_select($read = NULL, $write = NULL, $sock = array(socket_create (AF_INET, SOCK_RAW, 0)), 0, $usec); } } /** * XXX OBSOLETE XXX SEE kjwsql_from_uri() * * Creates a KjwSql object from a scheme://user:pass@server/database uri. * It stores references to the created objects. So, don't destroy() your * KjwSql objects prematurely! * * @param $uri An URI specifying database type, user, pass, host and database name. * @param $create_new Optional boolean to set to true if you do want a new/distinct object. * @return A KjwSql object or null on failure. */ function kjw_create_sql_from_uri($uri, $create_new = false) { require_once(dirname(__FILE__) . '/KjwSql.php'); return kjwsql_from_url($uri, $create_new); } /** * XXX OBSOLETE XXX SEE kjwsql_from_uri() * * Creates a KjwSql object using kjw_create_sql_from_uri() and calls the connect() * method on it. * * @param $uri An URI specifying database type, user, pass, host and database name. * @param $create_new Optional boolean to set to true if you do want a new/distinct object. * @return A connected KjwSql object or null on failure. */ function kjw_create_sql_from_uri_and_connect($uri, $create_new = false) { $Sql = kjw_create_sql_from_uri($uri, $create_new); if ($Sql->connect()) return $Sql; $Sql->destroy(); return null; } ?>