mysql running sql files April 21, 2008
Posted by chris in : SQL , add a commentFrom the MySQL command line use the database your SQL file will be affecting.
use database;
To execute the file.
source /path-to-file/file.sql
I always forget this one.
Is PostgreSQL licking their lips? April 17, 2008
Posted by chris in : SQL, rant , add a commentWith what many consider the bad news Sun announced regarding MySQL (certain features will be made closed source and available only to paying customers) is the other open source database, PostgreSQL, licking their lips? Probably. This can only help grow their user base. I happen to operate a moderately popular website music hosting website that runs on MySQL 5 using InnoDB and I am now considering looking into PostgreSQL.
Really this news couldn’t come at a better time. A complete rewrite of my web app is coming soon and the database design needed redone, so why not redo it in a completely open source solution. If Sun continues on this path they will alienate the hardcore open source geeks, this one is definitely going to research into the viability of PostgreSQL.
slick interfaces with javascript + MooTools + mochaUI April 8, 2008
Posted by chris in : ajax/dom/javascript , add a commentCheckout mochaUI I’ve been using it on a new web app I’m building and I’m very impressed with it. The code is very straightforward and the developers of mochaUI have put together some good documentation. It’s based on the MooTools javascript framework.
Creating slick interfaces can be as easy as this:
document.mochaUI.newWindow({
id: 1,
title: 'Add Note',
content: 'some text is here',
scrollbars: true,
modal: false,
width: 400,
height: 200
});
convert php object to an array April 8, 2008
Posted by chris in : php, software , 2commentsI’m really surprised that PHP 5 does not have built-in functionality for converting objects into arrays. Basically I had an Ajax function sending me a javascript object in JSON format to my PHP method. My method was already setup to handle an array, so after decoding the JSON into a PHP object and passed the object into this function.
function objectToArray($object)
{
$array=array();
foreach($object as $member=>$data)
{
$array[$member]=$data;
}
return $array;
}
The problem with this method is that it will only move public variables into the array. Anything that is private cannot be accessed. You can try type casting your PHP 5 object to an array.
$array = (array) $this;
When I did this I got some really strange characters in the array. It does not seem that there is an easy way to convert a PHP 5 object to an array. Your best bet is to write a custom function that either converts your objects variables into array elements or if you are connecting to a database, just return the result set that builds the object in array form.