Archive for the ‘PHP’ Category

Open source language reference

Sunday, November 16th, 2008

This is a project that is currently uncomplete, though i’ve put it online anyway to motivate myself to complete it faster =)

Its a reference that shows how to do common operations in php, perl and python.

You can view it here.

Dreamweaver mx2004 code color CakePHP template files - .thtml .ctp

Sunday, June 29th, 2008

You want to get dreamweaver to treat .thtml and .ctp files like php files. There are 2 config files that you’ll need to edit

View hidden file types

C:\Documents and Settings\[user]\Application Data\Macromedia\Dreamweaver MX 2004\Configuration\Extensions.txt

PHP,PHP3,PHP4,TPL,THTML,CTP:PHP Files

C:\Program Files\Macromedia\Dreamweaver MX 2004\Configuration\DocumentTypes\MMDocumentTypes.xml

<documenttype id=”PHP_MySQL” servermodel=”PHP MySQL” internaltype=”Dynamic” winfileextension=”php,php3,php4,thtml,ctp” macfileextension=”php,php3,php4,thtml,ctp” file=”Default.php” writebyteordermark=”false”>

Duplicating a database using PHP and mysqldump

Sunday, June 29th, 2008

Note i’m using VPS so there are no restrictions - you will only be able to do this on some shared hosts.

<?php

error_reporting(E_ALL);
include ‘../config/database.php’;
include ‘../vendors/MySQLConnection.php’; // personal wrapper, should be obvious what it’s doing
$config = new DATABASE_CONFIG();
$db_test = new MySQLConnection(
$config->test['host'],
$config->test['login'],
$config->test['password'],
$config->test['database']
);

ob_start();
system(’mysqldump -h ‘.$config->default['host'].’ -u ‘.$config->default['login'].’ -p’.$config->default['password'].’ --compact --add-drop-table ‘.$config->default['database']);
$s = ob_get_clean();
$a = split(’;',$s);
function t(&$s){$s=trim($s);}
array_walk($a,’t');
foreach ($a as $sql) {
$db_test->query($sql);
}

?>