Skip to main content

ADOBD for PHP – starting guidelines

It’s been a while since II ‘d like to share more on ADODB for PHP. Download the API here - http://adodb.sourceforge.net/ and copy to your PHP project folder. In this case am using XAMPP standard installation.

image

ADOdb is a database abstraction library (API/framework) for PHP that support mostly major database server, among others MySQL, MSSQL, Oracle etc...

image

Let say you have this table contact(idstaf, nama, jawatan, email,mobile,ext, web, idjabatan,imej), from database mobile_fstm.

SQL-dump

-- phpMyAdmin SQL Dump
-- version 4.0.9
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Aug 09, 2015 at 05:56 AM
-- Server version: 5.6.14
-- PHP Version: 5.5.6

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `mobile_fstm`
--
CREATE DATABASE IF NOT EXISTS `mobile_fstm` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `mobile_fstm`;

-- --------------------------------------------------------

--
-- Table structure for table `contact`
--
CREATE TABLE IF NOT EXISTS `contact` (
`idstaf` varchar(4) NOT NULL,
`nama` text NOT NULL,
`jawatan` text NOT NULL,
`email` text NOT NULL,
`mobile` text NOT NULL,
`ext` varchar(4) NOT NULL,
`web` text NOT NULL,
`idjabatan` varchar(5) NOT NULL,
`imej` text NOT NULL,
PRIMARY KEY (`idstaf`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `contact`
--
INSERT INTO `contact` (`idstaf`, `nama`, `jawatan`, `email`, `mobile`, `ext`, `web`, `idjabatan`, `imej`) VALUES
('0001', 'Muizz Salleh', 'Timbalan Dekan Mahasiswa', 'Muizz.Salleh@gmail.com', '+6012345234', '2313', 'http://muizz.com.my', 'JMM', 'muizz.png'),
('0132', 'Khirulnizam Abd Rahman', 'Pensyarah', 'khirulnizam@kuis.edu.my', '+60129034614', '2345', 'http://kerul.net', 'JSK', 'khirulnizam.jpg'),
('9999', 'Mohd Asyraf Chunawi', 'Trainee', 'masyrafchunawi@gmail.com', '+6012345678', '-', 'http://fstm.kuis.edu.my', 'JSK', 'asyraf.jpg');

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;


 


Connecting and fetching records from table.


<?php
//Test AdoBD...
$server="localhost";
$user="root";
$pwd="";
$db="mobile_fstm";

//incude adodb5 library
include('adodb5/adodb.inc.php');
//select what database server is used
$DB = NewADOConnection('mysql');
//provide database server connection details
$DB->Connect($server, $user, $pwd, $db);

// M'soft style data retrieval with binds
$rs = $DB->Execute("select * from contact");
//resultset available
while (!$rs->EOF) {
//just browse thru all records
print_r($rs->fields);
$rs->MoveNext();
echo "<hr>";
}

?>


 


Output


imageTada…



Incorporating jquery-mobile in the interface.


Code


<!DOCTYPE html>
<html>
<head>
<title>Direktori FSTM </title>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
</head>
<body>
<div data-role="page">

<div data-role="header"
data-add-back-btn="true" data-back-btn-text="Kembali" data-position="fixed">
<h1>Hubungi FSTM.kuis.edu.my</h1>
</div><!-- /header -->

<div role="main" class="ui-content">

<!-- display list staff -->
<?php

//contact(idstaf, nama, jawatan, email,mobile,ext, web, idjabatan,imej), from database mobile_fstm.
//include ("conn.cfg.php");
//Test AdoBD...
$server="localhost";
$user="root";
$pwd="";
$db="mobile_fstm";

//incude adodb5 library
include('adodb5/adodb.inc.php');
//select what database server is used
$DB = NewADOConnection('mysql');
//provide database server connection details
$DB->Connect($server, $user, $pwd, $db);
// get resultset as associative array
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;

// M'soft style data retrieval with binds
$rs = $DB->Execute("select * from contact");
//resultset available

?>

<ul data-role="listview" data-inset="true">
<?php
while (!$rs->EOF) {
//just browse thru all records
?>
<li>
<a href="#">
<?php echo $rs->fields['nama']; ?><br>
<?php echo $rs->fields['jawatan']; ?><br>
<?php echo $rs->fields['email']; ?><br>
<?php echo $rs->fields['mobile']; ?>
</a>
</li>
<?php

$rs->MoveNext();
//echo "<hr>";
}//end while EOF
?>
</ul>
<br>
</div>

<div data-role="footer" data-position="fixed">
<nav data-role="navbar">
<ul>
<li><a href="index.html" data-icon="home">Home</a></li>
<li><a href="info.html" data-icon="info">Info</a></li>
</ul>
</nav>
</div>
</div>
<!-- /page -->


</body>
</html>



ACTIVERECORD – all table and fields mapped to PHP class.


 


Training with sifoo blog.NasrulHazim.com


11222687_814863531962024_3626703495781469012_n11831633_814863391962038_5487095824298077093_n

Comments

Popular posts from this blog

Several English proverbs and the Malay pair

Or you could download here for the Malay proverbs app – https://play.google.com/store/apps/details?id=net.kerul.peribahasa English proverbs and the Malay pair Corpus Reference: Amir Muslim, 2009. Peribahasa dan ungkapan Inggeris-Melayu. DBP, Kuala Lumpur http://books.google.com.my/books/about/Peribahasa_dan_ungkapan_Inggeris_Melayu.html?id=bgwwQwAACAAJ CTRL+F to search Proverbs in English Definition in English Similar Malay Proverbs Definition in Malay 1 Where there is a country, there are people. A country must have people. Ada air adalah ikan. Ada negeri adalah rakyatnya. 2 Dry bread at home is better than roast meat home's the best hujan emas di negeri orang,hujan batu di negeri sendiri Betapa baik pun tempat orang, baik lagi tempat sendiri. 3 There's no accounting for tastes We can't assume that every people have a same feel Kepala sama hitam hati lain-lain. Dalam kehidupan ini, setiap insan berbeza cara, kesukaan, perangai, tabia...

Contact Us at blog.kerul.net

Powered by EMF HTML Contact Form

Applications of Web 2.0

Web 2.0 describes the changing trends in the use of World Wide Web technology and web design that aim to enhance creativity , secure information sharing, collaboration and functionality of the web. Web 2.0 concepts have led to the development and evolution of web-based communities and hosted services , such as social-networking sites , video sharing sites , wikis , blogs . Find a website or web application that conform to the criteria of Web 2.0. Put the name of the application and the URL in the comment below. Please provide your full name and matrix number. Make sure the application you choose is not already chosen by your friend in the previous comment.

The Challenges of Handling Proverbs in Malay-English Machine Translation – a research paper

*This paper was presented in the 14th International Conference on Translation 2013 ( http://ppa14atf.usm.my/ ). 27 – 29 August 2013, Universiti Sains Malaysia, Penang. The PDF version is here: www.scribd.com/doc/163669571/Khirulnizam-The-Challenges-of-Automated-Detection-and-Translation-of-Malay-Proverb The test data is here: http://www.scribd.com/doc/163669588/Test-Data-for-the-Research-Paper-the-Challenges-of-Handling-Proverbs-in-Malay-English-Machine-Translation Khirulnizam Abd Rahman, Faculty of Information Science & Technology, KUIS Abstract: Proverb is a unique feature of Malay language in which a message or advice is not communicated indirectly through metaphoric phrases. However, the use of proverb will cause confusion or misinterpretation if one does not familiar with the phrases since they cannot be translated literally. This paper will discuss the process of automated filtering of Malay proverb in Malay text. The next process is translation. In machine translatio...

Kursus Ionic 2021

Kursus terbaharu IONIC-5 Pengenalan sepintas lalu pembangunan apps Ionic WhatsApp kami di   http://laravel.wasap.my Dapatkan tarikh kursus terkini di  fb.com/khirulnizam Kolej Komuniti Temerloh September 2020 ILP Selandar Ogos 2020 Berikut senarai tutorial yang sedang kami bangunkan; HARI 1 & 2 Pengenalan IONIC dan cara pasang dalam Windows10 (   http://fstm.kuis.edu.my/blog/ionic-pengenalan/   ). Versi  PDF pengenalan & install IONIC Pasang plugin TypeSript (skrip utama dalam Ionic) dalam Sublime. Struktur asas Page dalam projek Ionic. Sharing intent kepada media sosial. Plugin Kamera dalam apps Ionic ( http://fstm.kuis.edu.my/blog/ionic-kamera/ ) HARI 2 & 3 IONIC + FIREBASE Firebase Ionic CRUD – masukkan rekod baharu ( download slides ) Firebase Ionic CRUD – baca rekod dan senaraikan ( download slides ) Firebase Ionic CRUD – perbaharui dan pada rekod (download slides) Kod contoh lengkap S-CRUD IONIC+FIREBASE di  GITHUB.com/khirulnizam/ionmasji...