Archive - 2007

Script for testing PHP ibm_db2 functioning

NOTE! Don't forget to setup ibm_db2.instance_name=db2inst1 correctly, as guideline in PHP :)

<?php
  $db_conn
= db2_connect("DATABASE=SAMPLE;HOSTNAME=127.0.0.1;PORT=50000;PROTOCOL=TCPIP;UID=db2inst1;PWD=CHANGE", '', '');
 
$cmdstr = 'SELECT "LASTNAME", "SALARY" FROM "EMPLOYEE"';
 
$stmt = db2_prepare($db_conn, 'SELECT COUNT(*) AS "NROWS" FROM ('. $cmdstr .')');
 
db2_execute($stmt);
 
$nrows = db2_fetch_object($stmt)->NROWS;
 
$stmt = db2_prepare($db_conn, $cmdstr);
 
db2_execute($stmt);
  echo
"<html><head><title>DB2 PHP Test</title></head><body>";
  echo
"<center><h2>DB2 PHP Test</h2><br>";
  echo
"<table border=1 cellspacing='0' width='50%'>\n<tr>\n";
  echo
"<td><b>Name</b></td>\n<td><b>Salary</b></td>\n</tr>\n";
  while (
$array = db2_fetch_assoc($stmt)) {
    echo
"<tr>\n";
    echo
"<td>" . $array["LASTNAME"] . "</td>";
    echo
"<td>$ " . number_format($array["SALARY"], 2). "</td>";
    echo
"</tr>\n";
  }
  echo
"<tr><td colspan='2'> Number of Rows: $nrows</td></tr></table><br>";
  echo
"<em>If you see data, then it works!</em><br>";
  echo
"</center></body></html>\n";
?>


December 30th

Server revamp with 3Ware 9650SE-8LPML!

Finally... Finally... I get the 3Ware 9650SE-8LPML for my server! Even the price of this card give me a bit of pain, the quality is need not to be question! A good BIOS UI, and I also get Debian's admin UI installed. Moreover, it is now able to fully utilize my new 9-bays server case (1 used for DVD) with hot swap plug-and-play supporting!

The most important is: the RAID array is able to be upgrade! This means you will not need to move all of your data away as backup, before rebuild and upgrade your array into a larger style. E.g. if I am now using 2 harddisk RAID1, I can add an additional harddisk and upgrade it as RAID5 whenever I hope to do so!

I have try mdadm and fake-raid before, but ALL are not suitable for production; BTW this card is something that I have asked for many years. I can't say more that this. If you are looking for a good RAID6 card for production, give the money, pay for it, and solve your problem now :-)

Here are some screenshots:

-->
My new case with 9 3.5" bays. 8 of them are coming with SATA hot swap drawer, so it is the best partner with 9650SE-8LPML!

-->
The superstar of today: my new 3Ware 9650SE-8LPML. It come with 8 LED connector, and able to figure out the status of each harddisk.

-->
Let's have a close look with it ;-)

-->
All after installation. 1GB DDR2 *4, AMD 64X2 4200+, 8 port SATA RAID6 card + case and Duel GB Lan! BTW, as I am now using a mATX motherboard, the card is now plugged into the PCIE 16X slot. Anyway, it is a server for running Debian etch with VMware for production and development, graphic is not its main concern ;-p

Anyway, story is not yet complete: the card is not supported by Debian etch kernel (2.6.18)! We need kernel at least with 2.6.19... So the solution is very simple:

  1. Get a Debian testing netinst ISO. It is coming with 2.6.22 so driver is included.
  2. During installation, install AS MINIMUM PACKAGES AS POSSIBLE! This means that you may even NOT install base packages when asking in tasksel. This is a bit tricky as we will make use of API-Pinning after installation. Complete the rest of installation as usual.
  3. After first reboot, let's setup APT-Pinning. So your Debian will forced to use etch package if possible, and just upgrade PART of packages to lenny if required (and that's why we should install as minimum package as we can, during system installation).
  4. call apt-get update to update your source list, and call tasksel --new-install to repeat the step you have been faced during system installation. Remember to get the "Standard system" install, and also don't forget the click of "manual package selection" in order to check all packages status before kick start ;-)

Moreover, the official 3DM2 installer is for Redhat-style system, but not Debian-style. So I need to get the unofficial Debian packages from here. Anyway, download them, simply run dpkg -i 3ware* and you will get it function :-)


December 24th

逆襲のchx

才剛開始把 Siren 部分的 issues 正名,以作集中處理,便又碰到有形的阻撓

As Siren is not a project on Drupal.org but an unofficial fork, I am removing it from issue titles to avoid confusion.

且並不是單一事件,而是全線受到狙擊:D6 的不在話下,連 D7 的亦不能倖免...

而事實上,同類的戲碼已經並非第一次上演... 司馬昭之心,其實路人皆知:先別說 Oracle/DB2/MSSQL,連已有的 PostgreSQL 的支援也想除之而後快...

這亦正正是我實行 "Code Siren" 的導火線:不受官方中反對聲音的阻撓,以實際工作成果為基礎,求取最大的支持。

說到 Drupal + Oracle 的研究,我並非第一人,這亦已經不是三兩天內的事情;但當問到何年何月才能成事,以現在的情況來看似乎仍然是緣木求魚...

有沒有人能給我一些好提議呢?


December 22nd

Tips and scripts for checking PHP5 OCI8/PDO_OCI + Oracle 11gR1 installation

In case of Oracle 11gR1, database name is no longer such simple as SID, but need to change into something call "Global Database Name" in "name.domain" format. So the testing script for OCI8 and PDO_OCI need to have some change, too.

Let's say we have a host call "localhost.localdoman" with a database SID as "AL32UTF8", its global database name should be "AL32UTF8.localdomain". In case of checking OCI8:

<?php
  $db_conn
= ocilogon("HR", "CHANGE", "//localhost.localdomain/AL32UTF8.localdomain");
 
$cmdstr = 'SELECT "LAST_NAME", "SALARY" FROM "HR"."EMPLOYEES"';
 
$parsed = ociparse($db_conn, $cmdstr);
 
ociexecute($parsed);
 
$nrows = ocifetchstatement($parsed, $results);
  echo
"<html><head><title>Oracle PHP Test</title></head><body>";
  echo
"<center><h2>Oracle PHP Test</h2><br>";
  echo
"<table border=1 cellspacing='0' width='50%'>\n<tr>\n";
  echo
"<td><b>Name</b></td>\n<td><b>Salary</b></td>\n</tr>\n";
  for (
$i = 0; $i < $nrows; $i++ ) {
    echo
"<tr>\n";
    echo
"<td>" . $results["LAST_NAME"][$i] . "</td>";
    echo
"<td>$ " . number_format($results["SALARY"][$i], 2). "</td>";
    echo
"</tr>\n";
  }
  echo
"<tr><td colspan='2'> Number of Rows: $nrows</td></tr></table><br>";
  echo
"<em>If you see data, then it works!</em><br>";
  echo
"</center></body></html>\n";
?>

In case of checking PDO_OCI:
<?php
  $db_conn
= new PDO('oci:dbname=//localhost.localdomain/AL32UTF8.localdomain', 'HR', 'CHANGE');
 
$cmdstr = 'SELECT "LAST_NAME", "SALARY" FROM "HR"."EMPLOYEES"';
 
$stmt = $db_conn->query($cmdstr);
 
$results = $stmt->fetchAll();
 
$stmt = $db_conn->query("SELECT COUNT(*) AS nrows FROM ($cmdstr)");
 
$nrows = $stmt->fetch(PDO::FETCH_OBJ)->NROWS;
  echo
"<html><head><title>Oracle PHP Test</title></head><body>";
  echo
"<center><h2>Oracle PHP Test</h2><br>";
  echo
"<table border=1 cellspacing='0' width='50%'>\n<tr>\n";
  echo
"<td><b>Name</b></td>\n<td><b>Salary</b></td>\n</tr>\n";
  for (
$i = 0; $i < $nrows; $i++ ) {
    echo
"<tr>\n";
    echo
"<td>" . $results[$i]["LAST_NAME"] . "</td>";
    echo
"<td>$ " . number_format($results[$i]["SALARY"], 2). "</td>";
    echo
"</tr>\n";
  }
  echo
"<tr><td colspan='2'> Number of Rows: $nrows</td></tr></table><br>";
  echo
"<em>If you see data, then it works!</em><br>";
  echo
"</center></body></html>\n";
?>


December 14th

Annual leave == 受難日

昨天可說是近來最累的一天...

0800: 起身
0900: 出門
1000: 到達西貢 (on-site maintenance service)。
1200: 完工,但要把電腦拿回家。
1300: 到達觀塘。放下電腦,和母親大人飲茶。
1400: 去上環,幫 Sky 拿袍。
1630: 到達大學。找 Jack Lee 談談。
1800: 還袍。
1900: 到達深水涉,買新 Server Case (SATA drawer x 8)。
1930: 到達旺角。和 Mike & Sky 食飯 + 吹水 + 打機。
2300: 回到家中...


December 8th

IBM DB2 v9.5: a lot of improvement!

At least IBM DB2 v9.5 give me more hope for Drupal/Siren driver development ;-)

Large identifier support lets you more easily port applications from other DBMS vendors. You will also find it easier to migrate data definition language (DDL) because you no longer need to shorten identifiers.

https://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db2....

In Version 9.5, the IBM® DB2 Data Server Client (formerly, the DB2 Client) comes with Hypertext Preprocessor (PHP) extensions; you no longer need to download them. Also, Version 9.5 builds on the Version 9.1 PHP support by providing a new extension called PDO_IBM.

https://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db2....

Version 9.5 provides new Unicode conversion tables that allow Big5-HKSCS clients to connect to and store HKSCS (Hong Kong Supplementary Character Set) data in Unicode databases.

https://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db2....

The scalar functions UPPER (UCASE) and LOWER (LCASE) can now change the case of text using a locale-sensitive conversion. By default, UPPER and LOWER convert characters in the string without considering locale. For some characters, there is a different mapping between uppercase and lowercase characters when using a locale-based conversion.

https://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db2....

P.S. too bad that LIKE is still not working as like as other database... see here.


November 11th

Howto find out which program opens tcp port?

For e.g. find out what opens port 3000:

lsof -i:3000

Display all PID and name of the program to which each tcp port belongs:

netstat -tlnp
ps aux | grep 3000
ps -eo pid,user,args,pid --sort user

Original post:
http://www.cyberciti.biz/motd-archive.php/15/find-out-which-program-open...


November 8th

Howto start ChatZilla directly, without opening Firefox?

http://chatzilla.hacksrus.com/faq/#start-cz

You can also start the browser with the -chat command line option. This will launch ChatZilla instead of a browser front end.


October 30th

System and service upgrade

Server is down in yesterday due to system and service upgrade. My server is now running with a new AX2 4200+ (TDP 65W), remove the useless SATA addon card, and also reinstall OS with Debian etch 40r1 amd64.

Try about Apache2.2 mod_authz_dbd (http://httpd.apache.org/docs/trunk/mod/mod_authz_dbd.html), check if it is able to replace the old mod_auth_mysql module, but fail. All private services authentication will keep as old standard: user login in this blog for a one-day-pass ticket. Document will update for this rule, soon.

Also install vexim (https://edin.no-ip.com/vexim/) + eGroupWare (https://edin.no-ip.com/egroupware/) as email service backend + SSL protection. I will use this suit and test it with my partners, about a new project. We are now hard working about this proposal, and I will soon report about its status. BTW, I guess some of my friends already know the detail of this project ;p

P.S. Still thinking about the 3Ware 9650SE RAID card... when can I have that? My Storage is now keep on ~90% usage...


October 19th

PostgreSQL 8.1 + phppgadmin on Debian mini-HOWTO

The default installation of PostgreSQL in Debian etch is not yet well configured, and so not suitable to work with phppgadmin, too. This simple mini-HOWTO will guide you though those critical but minor procedures, which will let all of your PostgreSQL functioning within 5 min :)