Introduction to php development with ids
Download
1 / 39

Introduction to PHP Development with IDS - PowerPoint PPT Presentation


  • 96 Views
  • Uploaded on

I13. Introduction to PHP Development with IDS. Jean Georges Perrin IIUG. Tuesday, October 4 th 2006 • 16:15 – 17:15. Platform: IDS, PHP. Agenda. Who am I? Architecture Requirements PHP Functions vs. PDO Your first application using the Command Prompt

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Introduction to PHP Development with IDS' - manning


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Introduction to php development with ids

I13

Introduction to PHP Development with IDS

Jean Georges Perrin

IIUG

Tuesday, October 4th 2006 • 16:15 – 17:15.

Platform: IDS, PHP


Agenda
Agenda

  • Who am I?

  • Architecture

  • Requirements

  • PHP

  • Functions vs. PDO

  • Your first application using the Command Prompt

  • Your first application using Eclipse

  • Your first web application


Agenda1
Agenda

  • Who am I?

  • Architecture

  • Requirements

  • PHP

  • Functions vs. PDO

  • Your first application using the Command Prompt

  • Your first application using Eclipse

  • Your first web application


Who am i
Who am I?

  • My Unix box usually answers…


Who am i outside of a unix box
Who am I (outside of a Unix box)?

  • Jean Georges Perrin

  • Development tools (xGL, Java EE, PHP)

  • Works with Informix products since ’97

  • IIUG board member since ’02

  • Lives in Strasbourg, France


A little more
A little more…

  • Application developer, started with Visual Basic, in the early 90s

  • In the web since 1994

  • Move to 4GL in 1997

  • Goals:

    • Webizing all things I touched (business apps, catalogs and i-4GL…)

    • Find the ease of use of Visual Basic


And you
And you…

  • Who knows 4GL?

  • Who knows Java?

  • Who thinks Java is difficult?

  • Who knows PHP?

  • Who thinks PHP is easy?

  • Who knows .net?

  • Who went to my Java lecture earlier this week?


Agenda2
Agenda

  • Who am I?

  • Architecture

  • Requirements

  • PHP

  • Functions vs. PDO

  • Your first application using the Command Prompt

  • Your first application using Eclipse

  • Your first web application


Architecture
Architecture

Application

Database Driver

Data


Agenda3
Agenda

  • Who am I?

  • Architecture

  • Requirements

  • PHP

  • Functions vs. PDO

  • Your first application using the Command Prompt

  • Your first application using Eclipse

  • Your first web application


Requirements
Requirements

  • #1 - IDS (from v7.x, but also works on OnLine and SE)

    • Where: www.iiug.org, www.informix.com

  • #2 - PHP (PHP v5.1.4)

    • Where: www.php.net

  • #3 - PDO driver

    • Where: pecl.php.net , pecl4win.php.net

  • #4 - Option: Eclipse (v3.2.0)

    • Where: www.eclipse.org


Agenda4
Agenda

  • Who am I?

  • Architecture

  • Requirements

  • PHP

  • Functions vs. PDO

  • Your first application using the Command Prompt

  • Your first application using Eclipse

  • Your first web application


A few words on php s history
A few words on PHP’s history

  • PHP stands for “PHP Hypertext Processor”

  • PHP is currently v5

  • Not well accepted by “serious” company


fglpc + fglgo

PHP

  • Hello, world… in PHP

  • Use of “PHP CLI”

  • Code snippets:

Source code is between <?php … ?> markers

A function is a function…

<?php

echo "Hello, world...";

?>

<?php

function main() {

echo ("Hello, world...");

}

main();

?>

DEMO

“Hello, world…” is always the same, in any language…


Php pros cons
PHP Pros & Cons

  • Procedural & Object Oriented (OO) development

  • Event driven programming model

  • User Interface (UI) & Business Logic (BL) tightly linked

  • Open architecture, open standards

  • General purpose development language

  • Becoming a standard

  • Looks like “hype” to some developers


4gl pros cons
4GL Pros & Cons

  • Procedural development

  • “Controlled” events

  • UI and BL somehow separated (.per & .4gl)

  • Proprietary solution

  • Business apps development language

  • Not a standard in industry

  • Hard to attract new developers


4gl and php
4GL and PHP

  • Weak typing

    • Assign an integer to a string

  • Not case sensitive

    • Well almost… not for variables.

  • 2 types of string

    • “parsed strings”

    • ‘unparsed strings’


Agenda5
Agenda

  • Who am I?

  • Architecture

  • Requirements

  • PHP

  • Functions vs. PDO

  • Your first application using the Command Prompt

  • Your first application using Eclipse

  • Your first web application


Two ways to access data
Two ways to access data

  • Function calls

    • ifx_* and ifxus_* functions

  • PHP Data Objects (PDO)

    • Set of “static” methods

    • More standard

    • Not to be compared to “real data objects”

    • Support for SERIAL in cvs


Pdo the way to go
PDO – The way to go

  • Clearly the future of data access in PHP

  • Standard way of talking to a database

  • Use a connection string, for IBM Informix:

$db = new PDO("informix:host=xeo;service=1526;►database=stores_demo;server=ol_xeo;protocol=olsoctcp;►EnableScrollableCursors=1;DB_LOCALE=EN_US.8859-1“ /* connection string */ ,

"informix"/* user */ ,

"informix"/* password */);


Agenda6
Agenda

  • Who am I?

  • Architecture

  • Requirements

  • PHP

  • Functions vs. PDO

  • Your first application using the Command Prompt

  • Your first application using Eclipse

  • Your first web application


Understanding php ini
Understanding php.ini

  • Convenient way to “extend” PHP.

  • Specify you want to use:

    • PDO

    • PDO Informix

extension=php_pdo.dll

extension=php_pdo_informix.dll

DEMO


Your first application using the command prompt
Your first application using the Command Prompt

  • Full source code (copy / paste):

<?php

$i = 0;

$db = new PDO("informix:host=xeo;service=1526;►database=stores_demo;server=ol_xeo;protocol=olsoctcp;►EnableScrollableCursors=1;DB_LOCALE=EN_US.8859-1“ /* connection string */ ,

"informix"/* user */ ,

"informix"/* password */);

$rs = $db->query("SELECT * from customer");

$colCount = $rs->columnCount();

for ($i = 0; $i < $colCount; $i++) {

$meta = $rs->getColumnMeta($i);

echo ($meta['name'] . "|");

}

echo ("\n");


Your first application 2
Your first application (2)

foreach ($rs as $row) {

for ($i = 0; $i < $colCount; $i++) {

echo ($row[$i] . "|");

}

echo ("\n");

}

?>

DEMO


Running a query
Running a query

  • One method is “query”

  • Code snippet:

$db = new PDO("informix:host=xeo;service=1526;►database=stores_demo;server=ol_xeo;protocol=olsoctcp;►EnableScrollableCursors=1;DB_LOCALE=EN_US.8859-1“ /* connection string */ ,

"informix"/* user */ ,

"informix"/* password */);

$rs = $db->query("SELECT * from customer");

Connection

Basic query


Accessing meta data
Accessing meta data

  • PDO allows you to access Metadata

  • Code snippet:

$colCount = $rs->columnCount();

for ($i = 0; $i < $colCount; $i++) {

$meta = $rs->getColumnMeta($i);

echo ($meta['name'] . "|");

}

echo ("\n");

Column count for the result set

Returns an array containing meta data

Accessing the ‘name’ parameter of the meta data


Dumping rows
Dumping rows

  • Basic browsing thru a result set using foreach

  • Code snippet:

foreach ($rs as $row) {

for ($i = 0; $i < $colCount; $i++) {

echo ($row[$i] . "|");

}

echo ("\n");

}

?>


Agenda7
Agenda

  • Who am I?

  • Architecture

  • Requirements

  • PHP

  • Functions vs. PDO

  • Your first application using the Command Prompt

  • Your first application using Eclipse

  • Your first web application


Your first application using eclipse
Your first application using Eclipse

  • Create a project

  • Add the code

  • Run it

DEMO


Agenda8
Agenda

  • Who am I?

  • Architecture

  • Requirements

  • PHP

  • Functions vs. PDO

  • Your first application using the Command Prompt

  • Your first application using Eclipse

  • Your first web application


Your first web application
Your first web application

  • The same application, but web

  • Strong embedding of HTML tags in the code

DEMO


Web source code
Web Source Code

<html>

<head><title>List of customers</title></head>

<body>

<?php

$i = 0;

$db = new PDO(

"informix:host=xeo;service=1526;database=stores_demo;server=ol_xeo;protocol=olsoctcp;EnableScrollableCursors=1;DB_LOCALE=EN_US.8859-1"/* connection string */ ,

"informix"/* user */ ,

"informix"/* password */);

$rs = $db->query("SELECT * from customer");

$colCount = $rs->columnCount();

echo ("<table>");

echo ("<thead><tr>");

for ($i = 0; $i < $colCount; $i++) {

$meta = $rs->getColumnMeta($i);

echo ("<td>" . $meta['name'] . "</td>");

}

echo ("</tr></thead>");


Web source code 2
Web Source Code (2)

echo ("<tbody>");

foreach ($rs as $row) {

//print_r();

echo("<tr>");

for ($i = 0; $i < $colCount; $i++) {

echo ("<td>" . $row[$i] . "</td>");

}

echo("</tr>");

}

echo ("</tbody></table>");

?>

</body>

</html>


Pros cons
Pros & Cons

  • The strong dependency between business logic and presentation layer is annoying

  • Introduction of MVC framework

PHP getting closer and closer to Java!


Conclusion
Conclusion

  • PHP now offers a standard way of accessing data

  • PHP is easy

  • PHP is rich

  • PHP runs:

    • Command line apps (batch)

    • Web apps

  • Frameworks are coming (Zend)


Complexity features

Eclipse

Java SE 5

Zend

Framework?

Java

J2EE

PHP 5

Java EE 5

4GL

PHP

OO in PHP 4

Complexity & Features

Difficult

Level of complexity / feature of languages over time

Easy

1994

1995

1996

1997

1998

1999

2000

2001

2002

2003

2004

2005

2006


And now
And now…

  • If you missed my other presentation:“Introduction to Java development with IDS”too bad!

  • Come to see me in San Jose (May 2007):“Introduction to EJB3 dev. with IDS and Viper”

  • (Give me good marks so I can be selected as best speaker of the conference and beat Darryl, Lester and Art - previous speakers).


And now seriously
And now (seriously)…

  • Download Eclipse (I guess you all have IDS already)

  • Download PHP

  • Get a book (O’Reilly has quite a few great books, I learnt PHP with “PHP for dummies”)

  • Join the development-tools forum on IIUG web site

  • Get started with a few examples


Jean georges perrin

I13

Introduction to PHP Development with IDS

Jean Georges Perrin

IIUG

[email protected]

[email protected]


ad