Posted 2 weeks ago

orbus005 – April 16, 1993 – Manchester

The Orb live @ Manchester ‘93

Posted 3 weeks ago

Doctrine ORM, Part 1

I’m planning on writing some detailed information about Doctrine in the future. For now, here are some notes of mine.

Getting Started

Bootstrap File

A bootstrap file is the best way to get started with Doctrine. It can contain all Global settings and information needed to connect to the database (or databases). The file is commonly called bootstrap.php:

<?php
require_once('Doctrine/lib/Doctrine.php');
spl_autoload_register(array('Doctrine','autoload'));
spl_autoload_register(array('Doctrine', 'modelsAutoload'));

$dsn = "mysql://stuff:stuff@host/db";
$connection = Doctrine_Manager::connection($dsn);
$manager = Doctrine_manager::getInstance();
$manager->setAttribute(Doctrine_Core::ATTR_MODEL_LOADING, Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
Doctrine_Core::loadModels('models');

Working with PDO

Because Doctrine utilizes PDO, you can perform some PDO-style actions with the $connection object:

<?php
require_once('bootstrap.php');

$query = $connection->prepare("select first_name from users");
$query->execute();
foreach ($query->fetchAll() as $row) {
    echo $row[0] . "\n";
}

Unfortunately it seems the $connection->query() function does not work through PDO.

Doctrine CLI

Doctrine provides some core actions that you are bound to repeat often. While it is possible to generate individual PHP files to act as tools (such as generate_models.php, it is much easier to work with the Doctrine CLI.

In order to get started with the CLI, create a file that looks like such:

<?php
require_once('bootstrap.php');
$cli = new Doctrine_Cli();
$cli->run($_SERVER['argv']);

You can then interface with the CLI by running this file on the command line:

$ php doctrine.php

Automatically Generating Models

To do any serious work with Doctrine, you first need to create Models that describe the database you are working with. This is easy with the CLI:

$ mkdir models
$ php doctrine.php generate-models-db models

You should now have several PHP classes in the models directory.

Creating a YAML Schema file

If you need to make any edits or changes to your existing database structure, it is easy to do with the Doctrine YAML format. You can create an initial YAML file with the CLI:

$ mkdir schema
$ php doctrine.php generate-yaml-db schema

Dumping Existing Data

If the existing database already has data, you can dump this data into a YAML file known as a “Fixture”:

$ mkdir fixtures
$ php doctrine.php dump-data fixtures

Reloading Your Database

After you make any changes to the schema and existing fixtures (for example, renaming a table), you can reload your database with the CLI. This will drop all tables, then re-create all tables with the new schema and reload all of the existing fixtures as well as regenerate all Models:

$ php doctrine.php build-all-reload

Relationships with Existing Databases

The database I am working with right now is rather sloppy and I haven’t been able to get automatic relationship recognition to work. Therefore, the solution is to manually define the relationships. This can either be done in the schema YAML or in the Models. If it is defined in the schema, you have the benefit of not having to redefine the relationship in the Models when they are regenerated.

Again, since the test database I am working with is old and inconsistent, even describing relationships in the Schema is not working (Foreign constraint fails). Therefore, I have to opt to describing the relationship through the Models. For example, if I have a users table and a messages table and each user can have many messages, I add the following to the Users class definition under setUp():

<?php
$this->hasMany('Messages as Messages', array(
        'local' => 'id',
        'foreign' => 'user_id'
));

Conclusion

That’s all I’ve got for Doctrine for now.

Posted 3 weeks ago

Quality Dub Techno

I discovered Dub Techno around two years ago. The style seemed great to me: cold, mechanical, analogue, and deep. However, the only problem was that I could rarely ever distinguish one song from another. Stereotypical Techno, I know, but it’s very apparent for Dub Techno. This frustrated me to no end and I would usually just end up not listening to the style at all.

Tonight I was cleaning out some music folders and came across some echocord. As much as I like the idea of dub techno, this music just didn’t sit right with me, so I deleted it.

Later I came across some Scion Versions. “Holy shit,” I thought, “this is good.”

Then I had an idea. I recovered some of the echocord and started switching between the two. The Scion Versions was by far better.

So not all Dub Techno sounds the same. It was a revelation to me.

Here’s an example. The below video is from the Scion Versions label:

And this one is echocord:

Posted 3 weeks ago
Posted 3 weeks ago

LPI and NOVELL partnership

I just got a free certification!

Posted 3 weeks ago

orbus004 – June 22, 1996 – Los Angeles

The Orb live @ Organic ‘96 Los Angeles

Posted 1 month ago

orbus003 – October 14, 1992 – Leeds

The Orb live @ Leeds University ‘92

Posted 1 month ago

Calgary - U of C offends Chinese government

“Academic degrees from the University of Calgary may no longer be recognized in China because that country’s government is upset the Dalai Lama was given an honourary degree last December by the university.”

I really hope that people will stop taking Universities seriously one day.

Posted 1 month ago

Massive Attack: Splitting the Atom

Posted 1 month ago