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

WebDev

http://blog.kerul.net PHP DEVELOPMENT TOOLS Download the XAMPP latest version from www.apachefriends.org . This installation file contains the Apache web server, PHP 5 and 4 interpreter, and the MySQL 5 Community edition. - download latest version MozillaFireFox (OpenSource web browser firefox) – download latest version Google Chrome – fastest web browser on earcth – fast download chrome here TEACHING PLAN Download the teaching plan here for Web/Internet Programming ( download ) NOTES HTML references HTML Editor -  http://www.sublimetext.com/ Lab 1: HTML Basics -  http://www.w3schools.com/html/ Lab 2: Responsive Design:  http://www.w3schools.com/html/html_responsive.asp Lab 3: HTML Forms  http://www.w3schools.com/html/html_forms.asp Lab 4: HTML 5  http://www.w3schools.com/html/html5_intro.asp Lab 5: Bootstrap for responsive Web -  http://www.w3schools.com/bootstra

Submit your blog address here

Create your own blog and send the address by submitting the comment of this article. Make sure to provide your full name, matrix and URL address of your blog. Refer to the picture below. Manual on developing a blog using blogger.com and AdSense, download here … Download Windows Live Writer (a superb offline blog post editor)

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.

Contact Us at blog.kerul.net

Powered by EMF HTML Contact Form