Location: PHPKode > scripts > Guaranix Full Text > guaranix-full-text/sqlite.php
<?

/***************************************************************************
 *   Copyright (C) 2006 by Cesar Rodas                                     *
 *   hide@address.com                                                      *
 *                                                                         *
 *   Permission is hereby granted, free of charge, to any person obtaining *
 *   a copy of this software and associated documentation files (the       *
 *   "Software"), to deal in the Software without restriction, including   *
 *   without limitation the rights to use, copy, modify, merge, publish,   *
 *   distribute, sublicense, and/or sell copies of the Software, and to    *
 *   permit persons to whom the Software is furnished to do so, subject to *
 *   the following conditions:                                             *
 *                                                                         *
 *   The above copyright notice and this permission notice shall be        *
 *   included in all copies or substantial portions of the Software.       *
 *                                                                         *
 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       *
 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    *
 *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
 *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR     *
 *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
 *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
 *   OTHER DEALINGS IN THE SOFTWARE.                                       *
 ***************************************************************************/

if (!defined('SQLITE_TIMEOUT'))
    define('SQLITE_TIMEOUT',1000,true);

class gnix_sqlite
{
    var $handler;
    var $last_query;
	var $version;

    function open($db='',$host='',$user='',$pass='')
    {
		$this->version = "SQLite";
        $this->handler = sqlite_open($db, 0666);
        sqlite_busy_timeout($this->handler,SQLITE_TIMEOUT);
		sqlite_exec($this->handler,"PRAGMA synchronous = OFF; PRAGMA vdbe_trace = OFF; PRAGMA parser_trace = OFF; PRAGMA vdbe_listing = OFF; PRAGMA default_cache_size = 65000; PRAGMA cache_size = 10000;");
    }
    
    function close()
    {
        sqlite_close($this->handler);
    }

    function query($query)
    {
		$query = stripslashes($query);
		
        $this->last_query = sqlite_query($this->handler,$query);
    }

    function getvalue()
    {
        return sqlite_fetch_array($this->last_query);
    }

    function count()
    {
        return sqlite_num_rows($this->last_query);
    }

    function lastinsert()
    {
        return sqlite_last_insert_rowid($this->handler);
    }

    function freequery()
    {
    }

    function exec($query)
    {
        sqlite_exec($this->handler,"BEGIN;");
		sqlite_exec($this->handler,$query);
		sqlite_exec($this->handler,"END;");
    }
	
	function insert($query)
	{
		sqlite_exec($this->handler,"begin;");
		sqlite_exec($this->handler,$query);
		sqlite_exec($this->handler,"commit;");
	}
}
?>
Return current item: Guaranix Full Text