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...

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)

Installing Google AdMob into Android Apps

Previously I wrote on why ads are needed to help maintaining an app. Read the article here http://blog.kerul.net/2011/05/generating-revenue-from-free-mobile.html . ---This is quite an old article. You may find the latest supporting AdMob 6.x in here http://blog.kerul.net/2012/08/example-how-to-install-google-admob-6x.html --- This is quite a long tutorial, there are 3 major steps involved. The experiment is done using Windows 7, Eclipse Helios and AdMob SDK 4.1.0 (which currently is the latest-during time of writing). STEP 1: Get the ads from AdMob.com To display the AdMob ads in your Android mobile apps, you need to register first at the admob.com . After completing the registration, login and Add Site/App. Refer to Figure 1. Figure 1 Choose the desired platform and fill in the details (as in Figure 2). Just put http:// in the Android Package URL if your app is not published in the market yet. And click Continue. Figure 2 Download the AdMob Android SDK, and save the zip fil...

Pemasangan Joomla! 1.7 pada pelayan web komputer anda

Latihan ini akan memasang sistem pengurusan kandungan laman web ke dalam pelayan web yang anda telah pasang sebelum ini . LANGKAH 1: Aktifkan Pelayan Web dan Pangkalan Data Aktifkan XAMPP Control Panel, melalui “ Start->All Programs->ApacheFriends->XAMPP Control Panel ”. Rajah 2.1 Pastikan pelayan web Apache dan pelayan pangkalan data MySQL diaktifkan dengan klik butang START. -> Rajah 2.2

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.