Archive for the ‘PHP’ Category

CakePHP: catching errors in Model->query()

In my recent CakePHP application I use some custom SQL queries that I fire at the database using the $model->query($sql) syntax. Works great, until you have an error in your $sql. I tried the obvious error handling with try … catch: try {   $this->Model->query(’INSERT INTO model WHERE id=invalid’); } catch (exception $ex) {   [...]

More »

Using preg_replace_callback on class methods

To prevent an error like preg_replace_callback() [function.preg-replace-callback]: Requires argument 2, ‘function_name’, to be a valid callback, use the following snippet: $text = preg_replace_callback(     ‘((http(s?)\://){1}\S+)’,     array(get_class($this), ‘function_name’),     $text ); The trick is to call the method like so: array(get_class($this), ‘__shortUrl’)

More »

CakePHP not showing new tables when using cake bake

When newly created tables don’t show up when using the console application cake bake then it’s time to clean out the model cache. The model cache is located in /app/tmp/cache/models/

More »

PHP frameworks compared

For my latest project, using PHP/MySQL, I wanted to use a framework to take some of the repetitive from me. I’ve looked at a number of frameworks, and here are some of my findings.

More »

DokuWiki, a worthy tiddlywiki alternative?

I’ve been playing with tiddlywiki a bit lately, and I haven’t been very impressed with it. I’ve been looking at some alternatives, because I do like the wiki way of creating and editing pages very much. And I found DokuWiki to be a very nice wiki. It’s light-weight It doesn’t require a database (pages are [...]

More »

What’s wrong with tiddlywiki?

There’s been a lot of buzz about tiddlywiki lately. Here’s a quote from the original tiddlywiki site: TiddlyWiki is a single html file which has all the characteristics of a wiki – including all of the content, the functionality (including editing, saving, tagging and searching) and the style sheet. Because it’s a single file, it’s [...]

More »