Crystal 0.3, codenamed "Typeless" released
I’m very proud to announce the 0.3 Milestone release of the database toolkit Crystal.
New features
Multiple database instances
In Crystal 0.3 you can create and use as many database instances as you need. For example you can define one instance for your master database server and several instances for your slave servers.
$master = Crystal::db('master');
$slave = Crystal::db('slave');
function create_entry()
{
$data = array('content' => 'My content is here', 'title' => 'Blog post title');
$master->insert('entries', $data)->execute();
}
function get_entries
(
return $slave->get('entries')->fetch_all();
)
You can learn a little bit more about the feature in this tutorial.
New configuration options
In Crystal 0.2 the only way to write database configuration was the file database.php in Crystal's config folder. Now you have several other configuration options:
// Configuration arrays
$config = array(
'username' => 'username',
'password'=> 'pass',
'database' => 'my_database',
'driver' => 'postgres'
);
$db = Crystal::db($config);
//Dynamic configuration files
$db = Crystal::db('path/to/configuration_file');
You can learn more about this feature here.
Simplified syntax
Writing array in your queries is time consuming and as a result your code is not as readable as it can be. That's why in Crystal 0.3 you can skip the array and just separate your values with colon or comma:
// Crystal 0.2
$db->select(array('column1, 'column2'))
$db->get('table')->where(array('id' => '1, 'status' => 'published))
// Crystal 0.3
$db->select('column1, column2')
$db->get('table')->where('id : 1, status : published')
$db->select('column1 : as a, column2 :as b')
New debug options
Your database server always returns the result in some kind of array. Arrays are very difficult to scan in a web browser and usually you must right click and view source if you want to see them formatted. In Crystal 0.3 you can just write print_as_table and you will get all your data nicely formatted in HTML table:
Website updates
Now Crystal has a simple bug tracker , which makes reporting and checking bugs a pretty easy task.
And of course the documentation has been updated to reflect the changes made in this new version.
Miscellaneous
The database wrapper class in Crystal 0.3 has much better unit test coverage. If you are not sure about the proper syntax of a function you can download and check the tests for more examples.
What's next
Crystal 0.3 is a release focused on stability and syntax optimizations mostly in the database wrapper. The next milestone - 0.4 will be focused on the database manipulation module. Most likely it will be available by the end of March 2010.