Learn the Rules, Break The Rules, and Create the New Ones...

Hi... My name is Rizky Prihanto. You can call me RQ, or Rizky either. I am currently living on Bandung, Indonesia. Had a lot of works and research about Enterprise Information Systems (majoring on education and e-governments). I have bunch of interests (some friends call it 'freakz') about MySQL Opensource Database and now I am one of the administrator of MySQL Indonesia User Group - the opensource community initialized by Sun Microsystems Indonesia.

My Company PT Cinox Media Insani, Bandung, Indonesia. I work here since 2008 and I take responsibility as Chief of Software Architect. My job is about planning, imaginating, fantasy-ing, concepting, and build the infrastructure of the new information systems (or app engines) which going to be implemented.

This blog This is my blog that represent my current opinion, research and experiences about anything in Software Engineering. Written since 2007 (actually) and has been vaccum for a lot of while. And now I wanna ressurrect this blog (optimistically) from the long-long-hibernation with something fresh and new ideas -- still about MySQL, software engineering, development, and may be something managerial here.

About the tagline I've learned the statement above from some paper written by Kent Beck about Extreme Programming (XP) methodology -- some sort of practical software development methods which have no boundaries. That's very inspiring me a lot. I have written some article on this blog that tell my interpretation about that statement here.

My Another Blogs I have classifying my blogs into some sort of genre. The blog that you read here right now is my primary blog that tell you (majoring) about IT stuff. But if you wanna look another side of me, you can visit here, here, here,or here. Hope it'll be interesting for some of you.

Credits I would thanks to Blogger for this great blog platform. Skinpress who designed this Wordpress template (which is bloggerized by Free Blogger Templates). My appreciate is also going to you who give your generously time for visiting my blog.

Proper Case di MySQL

Sial, tester gw ngisi inputan iseng bangedd : kya gini nih :

a qUicK BRowN fOx jUmPs oVeR biLl

Selaku penanggung jawab data(base), tentunya gw gag pengen inputan asal kya gtu lulus sensor n masuk ke tabel gw. Klo di VB, gw pernah bikin function PCase (singkatan dari ProperCase) yang fungsinya bakal 'menyesuaikan paksa' string ini (a qUicK BRowN fOx jUmPs oVeR biLl) menjadi ini (A Quick Brown Fox Jumps Over Bill). Berikut ini potongan function gw di VB :

Public Function PCase(ByVal strKalimat As String) As String
 PCase = StrConv(strKalimat, vbProperCase)
End Function

Nah, masalahnya gw ngga ndevelop di VB. Dan gw masih belum percaya ama programmer-programmer PHP gw (hihihihi...) ~ gw pengen bikin stored functionnya di MySQL. Yaa, itung-itung ngelengkapin koleksi String Function di MySQL lah.. masa udah ada LCASE() dan UCASE() tapi utk bikin Proper Case ngga ada...

Setelah sedikit googling dan obok-obok algoritma dikit, gw berhasil "meramu" stored function untuk ngonvert string menjadi proper-case. Silakan simak functionnya di bawah ini :

-- Function "xf_propercase" DDL

CREATE FUNCTION `xf_propercase`(str varchar(255)) RETURNS varchar(255) CHARSET utf8
 DECLARE punct CHAR(17) DEFAULT ' ()[]{},.-_!@;:?/';

 SET s = LCASE( str );
 WHILE i < LENGTH( str ) DO
  SET c = SUBSTRING( s, i, 1 );
  IF LOCATE( c, punct ) > 0 THEN
   SET bool = 1;
  ELSEIF bool=1 THEN
    IF c >= 'a' AND c <= 'z' THEN
      SET s = CONCAT(LEFT(s,i-1),UCASE(c),SUBSTRING(s,i+1));
      SET bool = 0;
    ELSEIF c >= '0' AND c <= '9' THEN
     SET bool = 0;   
    END IF;
  SET i = i+1;

nah, klo kita coba panggil ntu function, caranya gini :

mysql> select xf_propercase('a qUicK BRowN fOx jUmPs oVeR biLl');
| xf_propercase('a qUicK BRowN fOx jUmPs oVeR Bill') |
| A Quick Brown Fox Jumps Over Bill                  |
1 row in set

SUKSES!! cihuyy....

Rizky Prihanto
Software Architect PT Cinox Media Insani


Anonim mengatakan...

store functionnya disimpan di directori apa bos?
ane pake xampp for windows.
thx. before.

Anonim mengatakan...

apakah store function tersbt disimpan dalam php dan kemudian dipanggil dalam mysql apa bagaimana pak rizky?
mohon bantuannya. terima kasih.

Posting Komentar