Using Oracle in CakePHP 2.0

Standard

Update 22 May 2012
I just check with CakePHP 2.1.2 and it works fine. I also update some of the library and hopefully you guys can also contribute . https://bitbucket.org/odin88/cakephp-2.0-oracle

One of the clients where I work at is using Oracle 9i. We are still using CakePHP 1.3 for that project.The reason we still using the 1.x version because there is no support for Oracle database.

So i took some initiative to make it work. Mind you this is not using Oracle PDO because as you can see in this website they stated that it is still experimental.

I grab CakePHP 2.0.5 and add this database config

	public $default = array(
		'datasource' => 'Database/Oracle',
		'driver' => 'oracle',
		'connect' => 'oci_pconnect',
		'persistent' => false,
		'host' => 'ip_address',
		'login' => 'username',
		'password' => 'password',
		'database' => 'ip_address:1521/test',
		'prefix' => '',
		'schema' => 'schema_name'
	);

Create Oracle.php and put inside /lib/Cake/Model/Datasource/Database

U can copy the contents from oracle datasource from CakePHP 1.3 or just download from here.

in line 20 i put App:uses

App::uses('DboSource', 'Model/Datasource');

Rename the class name from

class DboOracle extends DboSource {

to

class Oracle extends DboSource {

And now we need to hack the core by just commenting line 650 and 661 DboSource.php located in /lib/Cake/Model/Datasource.

			//if ($this->hasResult()) {
				$first = $this->fetchRow();
				if ($first != null) {
					$out[] = $first;
				}
				while ($item = $this->fetchResult()) {
					if (isset($item[0])) {
						$this->fetchVirtualField($item);
					}
					$out[] = $item;
				}
			//}

The reason we comment $this->hasResult() is because the method is checking whether we are using PDOStatement or not .

	public function hasResult() {
		return is_a($this->_result, 'PDOStatement');
	}

// It is better to just override the function hasResult() in Oracle.php and return true;

function hasResult()
{
  return true;
}

So far I have tested functions like find(‘first’) and find(‘all’) and so far so good .. I will post any updates whether the Stored Procedure is working or not.
Enjoy ..

Update on 22 May 2012 – The stored procedure works fine 🙂

p/s : This tutorial is requested by @jose_zap so I try my best to explain. ^_^

Learn HTML5 at Microsoft Malaysia For Free !

Standard

The event is on saturday 17 December 2011. Register here at facebook event here or go to Sifoo page UReka for more info. You can get free T Shirt as well (first come first serve).

Copy from UReka :

uReka
“Experience the new HTML 5”
Web Matrix // Metro Style Design

Objektif : Mendedahkan penggunaan HTML 5 dalam pembangunan laman web serta diselitkan beberapa topik lain seperti “Metro Style Design”, “Web Matrix” dan lain-lain.

Anjuran: Microsoft & Sifoo.com

# Tentatif
08.30 – 09.30 : Breakfast
09.30 – 10.30 : HTML 5 by Walter Wong
10.30 – 11.30 : Metro Design by Daqing
11.30 – 13.00 : Lunch
13.00 – 13.30 : HTML 5 by LV
13.30 – 14.00 : Web Matrix by Seok Chern
14.00 – 14.30 : Window Azure by Hoong Fai
14.30 – 14.45 : Break
14.45 – 15.15 : IE 9 Top Sites by Matthew
15.15 – 15.45 : Q&A and Prize Presentation.

# Yuran Penyertaan
PERCUMA SAHAJA

# Cenderamata
Kami akan menyediakan t-shirt, “goodies”, dan sebagainya

Sila tempah kehadiran anda sekarang. Tempat adalah terhad.

TEMPAHAN TEMPAT
http://sifoo.com/blog/ureka
atau email informasi anda seperti dibawah ke syacz@yahoo.com

Nama Penuh:
No. Kad Pengenalan:
No. Telefon:
Alamat Emel:
Saiz t-shirt: S/M/L/XL/XXL

Senarai nama peserta akan dikemaskini dari semasa ke semasa.inflatable water slide hire

Sila hubungi pengelola dibawah untuk sebarang pertanyaan
Syacz – 60122801358
Imran – 60192625156

Too bad I cannot join because I have Infosys Alumni at Intekma Shah Alam .. It’s been 2 years after my Infosys training at Kings Hotel Melaka .. Hopefully I can meet my friends there.

Hari Minggu Saya Selepas 4 Bulan Kahwin

Standard

Ini merupakan entri pendek sempena lebih 4 tahun  bulan berkahwin (nampak sangat pemalas nak tulis blog sejak dah berbini .. )

Hujung minggu memang kebiasaan aku akan balik Klang dari Melaka .. bezanya lepas berkahwin aku dan isteri akan bergilir – gilir sama ada tidur di Klang atau di Serendah .

Last week adalah hari minggu yang agak pelik kerana tidak ditemani oleh isteri tercinta (sebab kene kidnap dibookingoleh kawannya untuk ke Batu Gajah dan Pulau Pinang)

Maka dengan ini adalah aktiviti saya seperti orang bujang

  • Download anime Fate Stay Zero dari episode 1 – 8
  • Jenguk2 kejap kerja ofis
  • Unboxing monitor baru saya Dell U2312HM
  • Menyelesaikan kerja freelance yang telah tertangguh selama lebih 3 bulan.
  • Waktu makan / tidur yang tidak tetap
  • Sempat singgah ke rumah makcik di Sungai Besi untuk format komputernya
  • Membeli Wii 2nd hand untuk adik di Tesco Cheras
  • Membeli 2 game Final Fantasy X (yang lame dah kene buang) dan Final Fantasy XII (beli dengan harapan dapat lepaskan tension)
Sekian sahaja untuk entri ini .. Sila stalk saya di Twitter untuk mahukan update yang lebih kerap.

Kehidupan Selepas Berkahwin

Standard

Dah lebih sebulan dari tarikh aku berkahwin dan apa yang aku boleh cakap so far so good 😛

Aku masih lagi bekerja di Melaka dan masih lagi membawa motor LC ulang alik melaka – klang setiap minggu cuma bezanya selepas kahwin aku akan mengambil isteri ku dan duduk di rumah parents kami secara bergilir – gilir . Jadi lokasi aku di hujung minggu sama ada di klang atau di serendah.

 

 

First week lepas kahwin merupakan perubahan yang mendadak .. bilik aku yang selama ni tak terurus .. baju berselerak .. dah ada orang tolong kemaskan .. Aku ada jugak dapat hadiah kahwin dari ofis iaitu sebuah vacuum cleaner dan aku gunakan waktu tu jugak untuk bersihkan bilik aku 😀

 

Lagi satu perubahan yang aku nampak .. aku bawak motor setiap minggu dah makin slow .. biasa bawak motor 130 – 140 KM/J dan tak sampai 2 jam dari melaka dah sampai ke klang tapi sekarang bawak maintain 100 KM/J so mengambil masa 2 jam setengah .. jadi bila terfikir nak bawak laju tu terpaksa la fikir dah ada isteri .. huhu

 

Kad untuk majlis di klang baru sahaja siap dan di design oleh WeddingKami . Just email kan nama dan alamat rumah anda supaya saya boleh pos kan kad atau refer sahaja website http://hassan-safinah.weddingkami.com/

 

My WeddingKami

Standard

I want to announce my online wedding card which can be found here – http://hassan-safinah.weddingkami.com/

Thanks to @tekong for the free WeddingKami since I won from the lucky draw few months ago .

Not to forget I still print the old traditional card and I will distribute later . Just email me odin88 (at) gmail.com your home address for me to post .

Wish me all the best this sunday . This is going to be my big step in my life and hopefully everything is going according to plan.

p/s : Dont forget to rsvp in the website .. and do post your wish for us. 🙂