Convert Figma logo to code with AI

catfan logoMedoo

The lightweight PHP database framework to accelerate the development.

4,889
1,148
4,889
54

Top Related Projects

9,606

Doctrine Database Abstraction Layer

2,001

A lightweight nearly-zero-configuration object-relational mapper and fluent query builder for PHP5.

Quick Overview

Medoo is a lightweight PHP database abstraction layer that simplifies database operations. It supports multiple database types, including MySQL, MSSQL, SQLite, and PostgreSQL, and provides a clean, easy-to-use API for performing common database tasks.

Pros

  • Simple and intuitive API for database operations
  • Supports multiple database types with a unified interface
  • Lightweight and fast performance
  • Prepared statements for enhanced security

Cons

  • Limited advanced features compared to full-fledged ORMs
  • May not be suitable for complex database operations
  • Documentation could be more comprehensive
  • Limited community support compared to larger frameworks

Code Examples

  1. Connecting to a database:
use Medoo\Medoo;

$database = new Medoo([
    'type' => 'mysql',
    'host' => 'localhost',
    'database' => 'my_database',
    'username' => 'root',
    'password' => 'secret'
]);
  1. Inserting data:
$database->insert('users', [
    'name' => 'John Doe',
    'email' => 'john@example.com',
    'age' => 30
]);
  1. Selecting data:
$users = $database->select('users', [
    'name',
    'email'
], [
    'age[>]' => 25
]);
  1. Updating data:
$database->update('users', [
    'age[+]' => 1
], [
    'id' => 1
]);

Getting Started

  1. Install Medoo using Composer:
composer require catfan/medoo
  1. Include Medoo in your PHP file:
require 'vendor/autoload.php';
use Medoo\Medoo;

$database = new Medoo([
    'type' => 'mysql',
    'host' => 'localhost',
    'database' => 'your_database',
    'username' => 'your_username',
    'password' => 'your_password'
]);
  1. Start using Medoo to perform database operations:
$data = $database->select('table_name', '*');

Competitor Comparisons

9,606

Doctrine Database Abstraction Layer

Pros of DBAL

  • More comprehensive and feature-rich database abstraction layer
  • Supports a wider range of database systems and advanced SQL features
  • Part of the larger Doctrine ecosystem, offering integration with other Doctrine components

Cons of DBAL

  • Steeper learning curve due to its complexity and extensive feature set
  • Heavier and may introduce more overhead for simpler database operations
  • Requires more configuration and setup compared to Medoo's simplicity

Code Comparison

Medoo:

$database = new Medoo([
    'database_type' => 'mysql',
    'database_name' => 'name',
    'server' => 'localhost',
    'username' => 'your_username',
    'password' => 'your_password'
]);

$data = $database->select('table', ['column1', 'column2'], ['id' => 1]);

DBAL:

$connectionParams = [
    'dbname' => 'mydb',
    'user' => 'user',
    'password' => 'secret',
    'host' => 'localhost',
    'driver' => 'pdo_mysql',
];
$conn = DriverManager::getConnection($connectionParams);

$queryBuilder = $conn->createQueryBuilder();
$result = $queryBuilder
    ->select('column1', 'column2')
    ->from('table')
    ->where('id = :id')
    ->setParameter('id', 1)
    ->executeQuery()
    ->fetchAllAssociative();
2,001

A lightweight nearly-zero-configuration object-relational mapper and fluent query builder for PHP5.

Pros of Idiorm

  • Lightweight and simple to use, with a minimal learning curve
  • Supports method chaining for more readable query construction
  • Flexible and allows for raw SQL queries when needed

Cons of Idiorm

  • Less feature-rich compared to Medoo, lacking advanced functionalities
  • Not actively maintained, with the last update in 2015
  • Limited database support (primarily MySQL, SQLite, and PostgreSQL)

Code Comparison

Medoo:

$data = $database->select("users", [
    "name",
    "email"
], [
    "age[>]" => 18
]);

Idiorm:

$users = ORM::for_table('users')
    ->select(['name', 'email'])
    ->where_gt('age', 18)
    ->find_many();

Key Differences

  • Syntax: Medoo uses array-based syntax, while Idiorm uses method chaining
  • Maintenance: Medoo is actively maintained, Idiorm is not
  • Features: Medoo offers more advanced features and wider database support
  • Learning curve: Idiorm may be easier for beginners due to its simplicity

Conclusion

While Idiorm offers simplicity and ease of use, Medoo provides a more comprehensive solution with active development and broader database support. The choice between the two depends on project requirements and developer preferences.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Build Status Total Downloads Latest Stable Version License Backers on Open Collective Sponsors on Open Collective

The lightweight PHP database framework to accelerate development.

Features

  • Lightweight - Single-file framework with minimal dependencies.

  • Easy - Simple and intuitive API for quick integration.

  • Powerful - Supports complex SQL queries, data mapping, and SQL injection prevention.

  • Compatible - Works with MySQL, MariaDB, PostgreSQL, SQLite, MSSQL, Oracle, Sybase, and more.

  • Friendly - Integrates seamlessly with Laravel, CodeIgniter, Yii, Slim, and other PHP frameworks.

  • Free - Licensed under MIT, free to use for any purpose.

Requirements

  • PHP 7.3 or later
  • PDO extension enabled

Get Started

Install via composer

Add Medoo to the composer.json configuration file.

$ composer require catfan/medoo

Then update Composer

$ composer update
// Require Composer's autoloader
require 'vendor/autoload.php';

// Import Medoo namespace
use Medoo\Medoo;

// Initialize database connection
$database = new Medoo([
    'type' => 'mysql',
    'host' => 'localhost',
    'database' => 'name',
    'username' => 'your_username',
    'password' => 'your_password'
]);

// Insert data
$database->insert('account', [
    'user_name' => 'foo',
    'email' => 'foo@bar.com'
]);

// Retrieve data
$data = $database->select('account', [
    'user_name',
    'email'
], [
    'user_id' => 50
]);

echo json_encode($data);

// [{
//    "user_name" : "foo",
//    "email" : "foo@bar.com",
// }]

Contribution Guidelines

Before submitting a pull request, ensure compatibility with multiple database engines and include unit tests when possible.

Testing & Code Style

  • Run phpunit tests to execute unit tests.
  • Use php-cs-fixer fix to enforce code style consistency.

Commit Message Format

Each commit should begin with a tag indicating the type of change:

  • [fix] for bug fixes
  • [feature] for new features
  • [update] for improvements

Keep contributions simple and well-documented.

License

Medoo is released under the MIT License.

Links

Support Our Other Product

Gear Browser - Web Browser for Geek

Gear Browser