Releases: catfan/Medoo
Medoo v2.1.2
- Bug fix for MySQL
rand()
.
Medoo v2.1.1
- Fix and improve Regex for matching column and table names.
Medoo v2.1.0
Raw for BETWEEN
$this->database->select("account", "user_name", [
"birthday[<>]" => [
Medoo::raw("to_date(:from, 'YYYY-MM-DD')", [":from" => '2015/05/15']),
Medoo::raw("to_date(:to, 'YYYY-MM-DD')", [":to" => '2025/05/15'])
]
]);
SELECT "user_name"
FROM "account"
WHERE
("birthday" BETWEEN to_date('2015/05/15', 'YYYY-MM-DD') AND to_date('2025/05/15', 'YYYY-MM-DD'))
LOBs for Oracle
Better support for inserting and updating LOBs for the Oracle database.
$fp = fopen('foo.dat', 'r');
$database->insert("ACCOUNT", [
"NAME" => "foo",
"DATA" => $fp
], "ID");
$database->update("ACCOUNT", [
"DATA" => $fp
], [
"ID" => 1
]);
- The regex for matching table name and column name is
[\p{L}_][\p{L}\p{N}@$#\-_]+
. - The performance is slightly improved.
Medoo v2.0.1
Quick bug fixed for v2.0.
- pdo connection undefined warning #962
- Duplicated table prefix for create() #963
- Connection warning while using socket #964
To see what's news about the next gen v2.0:
https://medoo.in/api/whatsnew
The Next-Gen v2.0
What is New v2.0
The milestone version of Medoo. We have updated the whole project with more standard and reliable code, including some new features and significant improvements. We also updated and redesigned the official documentation website.
Error initialization option
The new error option to indicate how to handle error information.
$database = new Medoo([
// Can be set as PDO::ERRMODE_SILENT, PDO::ERRMODE_WARNING, PDO::ERRMODE_EXCEPTION
// Default is PDO::ERRMODE_SILENT
'error' => PDO::ERRMODE_SILENT
]);
Simplified connection options
Those option names are simplified (you can still use the old one of course).
- database_type -> type
- database_name -> database
- server -> host
// New
$database = new Medoo([
'type' => 'mysql',
'host' => 'localhost',
'database' => 'name',
'username' => 'your_username',
'password' => 'your_password',
]);
// Old
$database = new Medoo([
'database_type' => 'mysql',
'database_name' => 'name',
'server' => 'localhost',
'username' => 'your_username',
'password' => 'your_password',
]);
New callback closure for select()
The high-performance way to output data immediately without loading it into memory.
$database->select("account", ["name"], function ($data) {
echo $data["name"];
});
New way to getting result from action()
To get the result from action(), you can provide the reference variable with the
use
keyword for the closure and then get it back from outside.
$result = "";
$database->action(function($database) use (&$result) {
$database->insert("account", [
"user_name" => "foo"
]);
$newId = $database->id();
$result = "The account is created, id is {$newId}.";
});
echo $result;
New way to get the error information
The function
$database->error()
is removed. Just read the$database->error
or$database->errorInfo
to get the error information last performed.
$database->insert("account", [
"user_name" => "foo"
]);
var_dump($database->error);
var_dump($database->errorInfo);
Last inserted id on Oracle
If want to the last inserted id on Oracle, provide the primary key as third parameter for
insert()
and get it fromid()
.
$database->insert("ACCOUNT", ["NAME" => "foo"], "ID");
var_dump($database->id());
Debug Logging
To debug the whole or the part of your project without putting
debug()
to every call, you can usebeginDebug()
to start debug logging, and then call debugLog() to stop it and get all debug logs as an array.
// Begin debug logging
$database->beginDebug();
// All those functions will not be executed but will save it as a debug log.
$database->select()......
$database->update().....
// Call debugLog() to stop debug logging and return all debug logs as an array.
var_dump($database->debugLog());
// Will output:
// array(2) {
// [0]=> string(10) "SELECT ... FROM"
// [1]=> string(10) "UPDATE ... SET ... WHERE ..."
// }
Join with Raw Object and Additional Condition
$database->select("post", [
"[>]comment" => [
"author_id" => "user_id",
"AND" => [
"rate[>]" => 50
]
],
"[>]account" => Medoo::raw("ON <post.author_id> = <account.user_id>")
], [
"post.content",
"comment.content",
"account.name"
]);
- PSR-2 standard.
- Test cases included.
- PHPDoc comments included.
- Drop support for PHP 5.4, the minimal requirement is PHP 7.3+.
- Better support for MSSQL and Oracle.
- Supports using Unicode character as table/column name.
- The official documentation website https://medoo.in is redesigned.
Enjoy it! :)
Medoo v1.7.10
- Emergency bug fix
Medoo v1.7.9
- Fixed some bugs about the raw query syntax
Medoo v1.7.8
- Fixed incorrect statement object for executing query
- Added more wildcard characters supported for like syntax
Medoo v1.7.7
- Fixed incorrect statement that calling debug after previous query #882
- Check table name for
tableQuote()
Medoo v1.7.6
- Fixed error information for statement
- Fixed data type conversion for select() with single column