Sabtu, 03 Agustus 2013

PHP Indonesia - Facebook: mohon bantuan nya master" php,, kenapa protected d...

PHP Indonesia - Facebook
PHP Indonesia is a community for everyone that loves PHP. Our focus is in the PHP world but our topics encompass the entire LAMP stack. Topics include PHP coding, to memcached handling, db optimizations, server stack, web server tuning, code deploying, hosting options and much much more. Youtube Channel : http://www.youtube.com/user/OurPHPIndonesia Twitter : @php_indonesia NOTE: Rules for Wall posting: https://www.facebook.com/groups/35688476100/doc/10151597056316101/ Daftar Keanggotaan : http://www.facebook.com/groups/35688476100/doc/10150671770741101/ 
mohon bantuan nya master" php,, kenapa protected d...
Aug 4th 2013, 02:31, by Asep Kurniawan

Asep Kurniawan 2:31am Aug 4
mohon bantuan nya master" php,, kenapa protected di awal function di bawah error ya ?????
coding program :
<?php

include "../koneksi.php";
/**
* Method untuk menyimpan data kedalam database
* string $tabel
* array $data : $key = kolom dan $value = data yang akan disimpan.
* @return boolean true : jika berhasil, false gagal
*protected dag ttidak terbaca awal function
*/
protected function simpan($tabel, $data)//protected tidak terbaca
{
$str = "INSERT INTO %s %s VALUES (%s)";
$kolom = array_keys($data);
$kolom = "(" . implode(',', $kolom) . ")";
foreach ($data as $value)
{
$nilai[] = "'$value'";
}
$nilai = implode(',', $nilai);
$qry = sprintf($str, $tabel, $kolom, $nilai);
return $this->execute($qry);
}

/**
* Method untuk melakukan query SELECT
* string $limit : off,len : off : awal indeks yang dibaca, len : banyak data
* @return array[array] : array 2 dimensi
*/
protected function select($tabel, $kolom="*", $where="", $limit="", $order="") {

if ($kolom != "*") {
$kolom = implode(',', $kolom);
}
if ($where != "") {
$where = "WHERE $where";
}
if ($limit != "") {
$limit = "OFFSET " . str_replace(',', ' LIMIT ', $limit);
}
if ($order != "") {
$order = "ORDER BY $order DESC";
}
$qry = "SELECT $kolom FROM $tabel $where $order $limit ";
$hasil = $this->execute($qry);
# echo $qry;
while ($baris = @mysql_fetch_assoc($hasil)) {
$data[] = $baris;
}
return $data;
}

/**
* mengubah data
*/
protected function update($tabel, $data, $where) {
foreach ($data as $key => $value) {
$set[] = "$key='$value'";
}
$set = implode(',', $set);
$str = "UPDATE $tabel SET $set WHERE $where";
return $this->execute($str);
}

/**
* menghapus data
*/
protected function delete($tabel, $where="") {
if ($where != "") {
$where = " WHERE " . $where;
}
$str = "DELETE FROM $tabel $where";
return $this->execute($str);
}

/**
* Mengeksekusi perintah SQL
*/
protected function execute($string, $data=false) {
if ($data) {
$hasil = mysql_query($string);
while ($baris = mysql_fetch_assoc($hasil)) {
$d[] = $baris;
}
return $d;
}
return mysql_query($string);
}

?>

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions

Tidak ada komentar:

Posting Komentar