All Projects → stefangabos → Zebra_database

stefangabos / Zebra_database

Licence: other
A compact, lightweight and feature-rich PHP MySQLi database wrapper

Projects that are alternatives of or similar to Zebra database

Hfish
安全、可靠、简单、免费的企业级蜜罐
Stars: ✭ 2,977 (+2937.76%)
Mutual labels:  mysql, redis, memcache
Gopherus
This tool generates gopher link for exploiting SSRF and gaining RCE in various servers
Stars: ✭ 1,258 (+1183.67%)
Mutual labels:  mysql, redis, memcache
Ninja Mutex
Mutex implementation for PHP
Stars: ✭ 180 (+83.67%)
Mutual labels:  mysql, redis, memcache
Kangaroo
SQL client and admin tool for popular databases
Stars: ✭ 127 (+29.59%)
Mutual labels:  database, mysql, redis
Db Tutorial
💾 db-tutorial 是一个数据库教程。
Stars: ✭ 128 (+30.61%)
Mutual labels:  database, mysql, redis
Endb
Key-value storage for multiple databases. Supports MongoDB, MySQL, Postgres, Redis, and SQLite.
Stars: ✭ 208 (+112.24%)
Mutual labels:  database, mysql, redis
Polluter
The easiest solution to seed database with Go
Stars: ✭ 146 (+48.98%)
Mutual labels:  database, mysql, redis
Phalcon Vm
Vagrant configuration for PHP7, Phalcon 3.x and Zephir development.
Stars: ✭ 43 (-56.12%)
Mutual labels:  mysql, redis, memcache
Easy Extends
一个简单快速安装PHP扩展的程序--最简单的方法就是使用Linux
Stars: ✭ 85 (-13.27%)
Mutual labels:  redis, memcache
Graphjin
GraphJin - Build APIs in 5 minutes with GraphQL. An instant GraphQL to SQL compiler.
Stars: ✭ 1,264 (+1189.8%)
Mutual labels:  database, mysql
Electrocrud
Database CRUD Application Built on Electron | MySQL, Postgres, SQLite
Stars: ✭ 1,267 (+1192.86%)
Mutual labels:  database, mysql
Supermarket
设计精良的网上商城系统,包括前端、后端、数据库、负载均衡、数据库缓存、分库分表、读写分离、全文检索、消息队列等,使用SpringCloud框架,基于Java开发。该项目可部署到服务器上,不断完善中……
Stars: ✭ 1,278 (+1204.08%)
Mutual labels:  mysql, redis
Kitura Redis
Swift Redis library
Stars: ✭ 84 (-14.29%)
Mutual labels:  database, redis
Docker Superset
Repository for Docker Image of Apache-Superset. [Docker Image: https://hub.docker.com/r/abhioncbr/docker-superset]
Stars: ✭ 86 (-12.24%)
Mutual labels:  mysql, redis
Butterfly
🔥 蝴蝶--【简单】【稳定】【好用】的 Python web 框架🦋 除 Python 2.7,无其他依赖; 🦋 butterfly 是一个 RPC 风格 web 框架,同时也是微服务框架,自带消息队列通信机制实现分布式
Stars: ✭ 82 (-16.33%)
Mutual labels:  mysql, redis
Go Sniffer
🔎Sniffing and parsing mysql,redis,http,mongodb etc protocol. 抓包截取项目中的数据库请求并解析成相应的语句。
Stars: ✭ 1,281 (+1207.14%)
Mutual labels:  mysql, redis
Cs Books
超过1000本的计算机经典书籍、个人笔记资料以及本人在各平台发表文章中所涉及的资源等。书籍资源包括C/C++、Java、Python、Go语言、数据结构与算法、操作系统、后端架构、计算机系统知识、数据库、计算机网络、设计模式、前端、汇编以及校招社招各种面经~
Stars: ✭ 1,215 (+1139.8%)
Mutual labels:  database, redis
Docker Lemp
🐳 Docker 快速搭建 LEMP 开发环境
Stars: ✭ 87 (-11.22%)
Mutual labels:  mysql, redis
Hedis
Hedis can retrieve data from **ANY** database directly via Redis
Stars: ✭ 90 (-8.16%)
Mutual labels:  database, redis
Zhihuspider
知乎用户公开个人信息爬虫, 能够爬取用户关注关系,基于Python、使用代理、多线程
Stars: ✭ 92 (-6.12%)
Mutual labels:  mysql, redis
zebrajs

Zebra Database

A compact (one-file only), lightweight yet feature-rich PHP MySQLi database wrapper providing methods for interacting with MySQL databases that are more secure, powerful and intuitive than PHP's default ones.

Latest Stable Version Total Downloads Monthly Downloads Daily Downloads License

Zebra_Database supports transactions and provides ways for caching query results either by saving cached data to the disk, in the session, by using memcache or redis.

The library provides a comprehensive debugging interface with detailed information about the executed queries: execution time, returned/affected rows, excerpts of the found rows, error messages, backtrace information, etc. It can also automatically EXPLAIN SELECT queries (so you don't miss those keys again!).

It encourages developers to write maintainable code and provides a better default security layer by encouraging the use of prepared statements, where parameters are automatically escaped.

The code is heavily commented and generates no warnings/errors/notices when PHP's error reporting level is set to E_ALL.

📔 Documentation

Check out the awesome documentation!

Support the development of this library

If you like this project please star it on GitHub.
If you are feeling very generous, you can also buy me a coffee through PayPal.
Thank you!

Star it on GitHub Donate

Features

  • it uses the mysqli extension extension for communicating with the database instead of the old mysql extension, which is officially deprecated as of PHP v5.5.0 and will be removed in the future; this is not a wrapper for the PDO extension which is already a wrapper in itself!

  • offers lots of powerful methods for easier interaction with MySQL

  • supports unbuffered queries

  • provides a better security layer by encouraging the use of prepared statements, where parameters are automatically escaped

  • provides a very detailed debugging interface with lots of useful information about executed queries; it also automatically EXPLAINs each SELECT query

  • supports caching of query results to the disk, in the session, or to a memcache or to a redis server

  • has really good documentation

  • code is heavily commented and generates no warnings/errors/notices when PHP's error reporting level is set to E_ALL

Zebra_Database's debugging console

Requirements

PHP 5.4.0+ with the mysqli extension activated, MySQL 4.1.22+

For using memcache as caching method, PHP must be compiled with the memcache extension and, if memcache_compressed property is set to TRUE, needs to be configured with –with-zlib[=DIR]

For using redis as caching method, PHP must be compiled with the redis extension and, if redis_compressed property is set to TRUE, needs to be configured with –with-zlib[=DIR]

Installation

Download the latest version, unpack it, and load it in your project

require_once 'Zebra_Database.php';

Installation with Composer

You can install Zebra_Database via Composer

composer require stefangabos/zebra_database

How to use

Connecting to a database
// instantiate the library
$db = new Zebra_Database();

// connect to a server and select a database
$db->connect('host', 'username', 'password', 'database');
Running queries
// question marks will re replaced automatically with the escaped values from the array
// I ENCOURAGE YOU TO WRITE YOUR QUERIES IN A READABLE FORMAT, LIKE BELOW
$db->query('
    SELECT
    	column1,
        column2,
        column3
    FROM
    	tablename1
    	LEFT JOIN tablename2 ON tablename1.column1 = tablename2.column1
    WHERE
    	somecriteria = ? AND
        someothercriteria = ?
', array($somevalue, $someothervalue));

// any fetch method will work with the last result so
// there's no need to explicitly pass that around

// you could fetch all records to one associative array...
$records = $db->fetch_assoc_all();

// you could fetch all records to one associative array
// using the values in a specific column as keys
$records = $db->fetch_assoc_all('column1');

// or fetch records one by one, as associative arrays
while ($row = $db->fetch_assoc()) {
    // do stuff
}
An INSERT statement
// notice that you can use MySQL functions in values
$db->insert(
    'tablename',
    array(
        'column1'      => $value1,
        'column2'      => $value2,
        'date_updated' => 'NOW()'
    )
);
An UPDATE statement
// $criteria will be escaped and enclosed in grave accents, and will
// replace the corresponding ? (question mark) automatically
// also, notice that you can use MySQL functions in values
// when using MySQL functions, the value will be used as it is without being escaped!
// while this is ok when using a function without any arguments like NOW(), this may
// pose a security concern if the argument(s) come from user input.
// in this case we have to escape the value ourselves
$db->update(
    'tablename',
    array(
        'column1'      => $value1,
        'column2'      => 'TRIM(UCASE("value2"))',
        'column3'      => 'TRIM(UCASE("'' . $db->escape($value3) . "))',
        'date_updated' => 'NOW()'
    ),
    'criteria = ?',
    array($criteria)
);

There are over 40 methods and 20 properties that you can use and lots of things you can do with this library. I've prepared an awesome documentation so that you can easily get an overview of what can be done. Go ahead, check it out!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].