Skip to content

Medoo 1.4

Compare
Choose a tag to compare
@catfan catfan released this 10 May 03:44
· 331 commits to master since this release

Make Medoo Great Again

The most greatest update on Medoo history. This version included a lot of significant improvements that obviously increasing the performance and flexibility. We also redesign our official website, providing better useful content for documentation.

Prepared statement ready

Medoo is now using prepared statement for inside query execution. This will increase the query performance and also prevent SQL injection.

Add supported for data type declaration

$data = $database->select("post", [
	"[>]account" => ["user_id"]
], [
	"post.post_id",
 
	"profile" => [
		"account.age [Int]",
		"account.is_locked [Bool]",
		"account.userData [JSON]"
	]
], [
	"LIMIT" => [0, 2]
]);
 
echo json_encode($data);

// Output data
[
	{
		post_id: "1",
		profile: {
			age: 20,
			is_locked: true,
			userData: ["foo", "bar", "tim"]
		}
	},
	{
		post_id: "2",
		profile: {
			age: 25,
			is_locked: false,
			userData: ["mydata1", "mydata2"]
		}
	}
]

Add supported for LOBs and resources data type for insert() and update()

class Foo {
	var $bar = "cat";
 
	public function __wakeup()
	{
		$this->bar = "dog";
	}
}
 
$object_data = new Foo();
 
$fp = fopen($_FILES[ "file" ][ "tmp_name" ], "rb");
 
$database->insert("account", [
	// String value
	"user_name" => "foo",
 
	// Integer value
	"age" => 25,
 
	// Boolean value
	"is_locked" => true,
	
	// Array value
	"lang" => ["en", "fr", "jp", "cn"],
 
	// Array value encoded as JSON
	"lang [JSON]" => ["en", "fr", "jp", "cn"],
 
	// Object value
	"object_data" => $object_data,
 
	// Large Objects (LOBs)
	"image" => $fp
]);

Logging option

We added a logging option for initialization. Logging feature will be disabled for better performance and less memory consumption.

$database = new Medoo([
	"database_type" => "mysql",
	"database_name" => "name",
	"server" => "localhost",
	"username" => "your_username",
	"password" => "your_password",
 
	// Enable logging
	"logging" => true,
]);

New query() API, supports prepared statement

$data = $database->query(
	"SELECT * FROM account WHERE user_name = :user_name AND age = :age", [
		":user_name" => "John Smite",
		":age" => 20
	]
)->fetchAll();

Additional changes

  • Supports JSON decode
  • Supports multiple GROUP by
  • Improve MATCH full-text search
  • Improve data mapping performance
  • Improve all regex matching
  • Improve MSSQL and Oracle database support

Upgrading Medoo 1.2 to Medoo 1.4

There is only one change required

// From
$database->insert("account", [
	"user_name" => "foo",
	"email" => "[email protected]",
	"age" => 25,
	"(JSON) lang" => ["en", "fr", "jp", "cn"]
]);

// To
$database->insert("account", [
	"user_name" => "foo",
	"email" => "[email protected]",
	"age" => 25,
	"lang [JSON]" => ["en", "fr", "jp", "cn"]
]);

Code changes for upgrading older version to Medoo 1.4, read more
https://medoo.in/api/upgrade

New designed official website is now HTTPS also
https://medoo.in