Skip to content

Medoo v1.5

Compare
Choose a tag to compare
@catfan catfan released this 21 Nov 12:23
· 259 commits to master since this release

We are happy to release the v1.5 with full of expectation. This version have included the most important feature - raw object, that can help you to build complex query conveniently and safely. We also optimized the whole project with better code organization and readability for better performance.

Using SQL Functions

Medoo 1.5 is now using raw object for complex query. The old version # is not supported anymore. It's much more powerful.

Medoo 1.5+

$database->insert("account", [
	"user_name" => "bar",
	"uid" => Medoo::raw("UUID()")
]);

Using Regular Expression

$data = $database->select('account', [
	'user_id',
	'user_name'
], [
	'user_name[REGEXP]' => '[a-z0-9]*'
]);
 
// SELECT "user_id","user_name"
// FROM "account"
// WHERE "user_name" REGEXP '[a-z0-9]*'

Outputting Query With Database Default Quote Identifier

As for Medoo 1.5, debug() will output the query with database default quote identifier from now. Like MySQL is using col and MSSQL is using [col] for quoting column. Keep in mind that, this is only output for debugging the query. Medoo is actually using standard quote identifier for internal execution for all database.

$data = $database->debug()->select('account', [
	'user_id',
	'user_name'
], [
	'user_name' => 'foo'
]);
 
// For MySQL
// SELECT `user_id`,`user_name`
// FROM `account`
// WHERE `user_name` = 'foo'
 
// For MSSQL
// SELECT [user_id],[user_name]
// FROM [account]
// WHERE [user_name] = 'foo'
 
// For Others
// SELECT "user_id","user_name"
// FROM "account"
// WHERE "user_name" = 'foo'

MSSQL Connection

Medoo 1.5 will use pdo_sqlsrv drvier for MSSQL database connection with all platform by default, because Microsoft released new pdo_sqlsrv driver for both Linux and Windows platform. If you want to use old version dblib driver, you can specify driver option with dblib value for using this driver.

$database = new Medoo([
	'database_type' => 'mysql',
	'database_name' => 'name',
	'server' => 'localhost',
	'username' => 'your_username',
	'password' => 'your_password',
 
	// [optional] If you want to force Medoo to use dblib driver for connecting MSSQL database
	'driver' => 'dblib'
]);

Improvements

  • Add possibility to use column alias and data type declaration at the same time
  • Improve transaction call
  • Improve replace logic
  • Code simplified and improved performance
  • Improve error info return for empty statement

Bug Fixes

  • Select number does not return floating point
  • Execute commands for SQLite initialization
  • Fix MSSQL LIMIT error
  • Fix has() method error with different database return
  • PDO::PARAM for double value