WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Mobile Dev World

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : SQLite PHP Database Wrapper
Categories : PHP, PHP Classes, Databases, SQLite, Beginner Guides Click here to Update Your Picture
Alix Axel
Date : Apr 28th 2009
Grade : 1 of 5 (graded 1 times)
Viewed : 1868
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Alix Axel
Action : Grade This Code Example
Tools : My Examples List

 
Like this code?
Show the author your appreciation.
Submit your own code examples 
 

A minimalistic wrapper for SQLite Databases.
<?php

class SQLite
{
    public
$connection = null;

    function
Affected_Rows()
    {
        if (
is_resource($this->connection) === true)
        {
            return
sqlite_changes($this->connection);
        }

        return
false;
    }

    function
Connect($database)
    {
        if (
is_file($database) === true)
        {
           
$this->connection = sqlite_open($database) or trigger_error(sqlite_error_string(sqlite_last_error($this->connection)), E_USER_ERROR);

            if (
is_resource($this->connection) === true)
            {
                return
true;
            }
        }

        return
false;
    }

    function
Disconnect()
    {
        if (
is_resource($this->connection) === true)
        {
            return
sqlite_close($this->connection);
        }

        return
false;
    }

    function
Insert_ID()
    {
        if (
is_resource($this->connection) === true)
        {
            return
sqlite_last_insert_rowid($this->connection);
        }

        return
false;
    }

    function
Query($sql, $type = 'assoc')
    {
        if (
is_resource($this->connection) === true)
        {
           
$query = sqlite_query($this->connection, $sql) or trigger_error(sqlite_error_string(sqlite_last_error($this->connection)), E_USER_WARNING);

            if (
is_resource($query) === true)
            {
                return
sqlite_fetch_all($query, constant('SQLITE_' . strtoupper($type)));
            }

            if (
$query === true)
            {
                switch (
strtoupper(substr(trim($sql), 0, strpos(trim($sql), ' '))))
                {
                    case
'INSERT':
                        return
$this->Insert_ID();
                    break;

                    case
'UPDATE':
                    case
'REPLACE':
                    case
'DELETE':
                        return
$this->Affected_Rows();
                    break;
                }

                return
true;
            }
        }

        return
false;
    }

    function
Quote($string)
    {
        if (
get_magic_quotes_gpc() === true)
        {
           
$string = stripslashes($string);
        }

        return
'\'' . sqlite_escape_string(trim($string)) . '\'';
    }

    function
Tick($string)
    {
       
$string = explode('.', str_replace(array('[', ']'), '', $string));

        foreach (
$string as $key => $value)
        {
            if (
$value != '*')
            {
               
$string[$key] = '[' . trim($value) . ']';
            }
        }

        return
implode('.', $string);
    }
}
?>


Usage:
Identical to http://www.weberdev.com/get_example-4811.html



PHP5 SQLite Abstraction class
Categories : PHP, PHP Classes, SQLite, Databases
Specify your connection settings and create a link to a MySQL database.
Categories : PHP, PHP Classes, Databases, MySQL, Beginner Guides
Cut your MySQL Connections to 1 line of code
Categories : PHP, Beginner Guides, Databases, MySQL
MySQL Connection/Query Class
Categories : Databases, MySQL, PHP, PHP Classes
Simple class for accessing databases like MSSql Server, Oracle etc by Raju
Categories : PHP, MS SQL Server, Databases, PHP Classes, Oracle
for each record, do this to the first record, and do that to any subsequent record
Categories : PHP, Databases, MySQL, Beginner Guides
phpFormGenerator for Dynamic Form Generation from MySQL
Categories : PHP, PHP Classes, MySQL, Databases, HTML and PHP
Create and restore backup of MySQL databases
Categories : MySQL, Databases, PHP, PHP Classes, Complete Programs
Convert a File database into MySQL
Categories : PHP, Filesystem, Databases, MySQL, Beginner Guides
DBXML- A Class to backup databases in XML Format using web interface
Categories : PHP, PHP Classes, Databases, MySQL, XML
This class splits the results of the query into multiple pages like what the search engine does.
Categories : PHP Classes, PHP, MySQL, Databases
MySQL Class to ease Database connectivity
Categories : MySQL, PHP Classes, Databases, PHP
News management class
Categories : PHP, PHP Classes, Beginner Guides
DBE - Database Expander: Edit PostgreSQL individual database tables online via your Web browser!
Categories : PostgreSQL, Complete Programs, Databases, PHP Classes, PHP
ADODB Database Wrapper Abstraction Library for PHP: MySQL, MSSQL, Oracle, Interbase,ODBC, Microsoft Access and FoxPro.
Categories : PHP Classes, Databases, PHP, General SQL, ODBC