This document discusses PHP Data Objects (PDO), a database abstraction layer for PHP. PDO provides a common interface for accessing various database systems and aims to eliminate inconsistencies in different database extensions. It allows prepared statements and bound parameters to help prevent SQL injection attacks. PDO is included with PHP 5.1 and later and provides drivers for many database systems including MySQL, PostgreSQL, SQLite, and SQL Server.
Apache and PHP: Why httpd.conf is your new BFF!Jeff Jones
Apache's configuration files can be used to configure how Apache operates, but they can also be used to configure PHP and how Apache httpd interacts with PHP. In this talk, Jeff explains the different ways Apache can be configured, explains many of the useful config options available for Apache modules, including our own mod_php, and showcases example of how they can be used with, and instead of, your PHP code.
Apache and PHP: Why httpd.conf is your new BFF!Jeff Jones
Apache's configuration files can be used to configure how Apache operates, but they can also be used to configure PHP and how Apache httpd interacts with PHP. In this talk, Jeff explains the different ways Apache can be configured, explains many of the useful config options available for Apache modules, including our own mod_php, and showcases example of how they can be used with, and instead of, your PHP code.
CouchDB for Web Applications - Erlang Factory London 2009Jason Davies
CouchDB is built "of the Web" and it's very exciting to convert the immense
power that CouchDB provides into a usable, real-world Web application. In this
talk I cover case studies of real-world applications that use CouchDB,
including some that can be served from CouchDB itself, and how CouchDB can
shape your Web applications to be highly scalable and flexible by embracing
HTTP philosophies, JavaScript and schemaless documents.
Google's Go is a relatively new systems programming language that has recently gained a lot of traction with developers. It brings together the ease and efficiency of development in modern interpreted languages like Python, Perl, and Ruby with the efficiency and safety of a statically typed, compiled language like C/C++ and Java.
On top of that, Go is a language built for modern hardware and problems. With built-in support for concurrency, programmers can easily build software to scale up to today's many-core beasts. Programming in Go is really nice, and in this tutorial, you will learn why.
We will cover an introduction to the Go programming language, and together we will build a multi-user network service demonstrating all of the major principles of programming in Go.
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...Alexander Lisachenko
It is believed that the Symfony framework is quite heavy and it can be difficult to develop a website that will be able to work under the high load. It is true, but does this mean that it is impossible to implement a dynamic caching and to update only a small part of entire page as data is updated? This talk will give your an answer to that. It is Varnish, ESI-blocks and load balancing. With hundreds of thousands of unique visitors and million hits a day, we continue to use Symfony, and do not see any problems.
Introducing RaveJS: Spring Boot concepts for JavaScript applicationsJohn Hann
Modern JavaScript frameworks have become quite sophisticated. Unfortunately, they have also become quite complicated. The demos and sample projects for these frameworks look deceptively simple. However, to build and deploy real applications, developers must scaffold, configure, and maintain a tremendous amount of intricate machinery. Until recently, the Java world wasn't very different. Spring Boot finally made it easy to create stand-alone, production-grade Spring Applications that can you can "just run". Can we do the same for JavaScript? Yes, we can! Introducing RaveJS. Rave eliminates configuration, machinery, and complexity. Stop configuring and tweaking machinery such as file watchers, minifiers, and transpilers just to get to a runnable app. Instead, go from zero to "hello world" in 30 seconds. In the next 30 seconds, easily add capabilities and frameworks to your application simply by installing *Rave Extensions* and *Rave Starter* packages from npm and Bower, the leading JavaScript package managers. Finally, install additional *Rave Extension* packages to apply your favorite build, deploy, and testing patterns.
Imagine for a while that Rails wouldn't exist. How would we write a MVC app from scratch?
Rack provides a minimal interface for developing web applications in Ruby. In fact it's the solid foundation of all major Ruby powered web frameworks.
During this talk we will dive deep into Rack. We will see the smallest possible Rack Application and learn how it works, by studying Rack internals. We will grow the Application step by step till we implement it in simple MVC style.
Après une douzaine d'années à faire du développement backend sur Symfony, je me retrouve aujourd'hui directeur technique d'une agence qui travaille exclusivement sur Laravel, quel choc !
En France quand on parle de Laravel, le débat tourne vite au troll (parce que Symfony = cocorico, donc Laravel forcément = satan). Mais loin des clichés Laravel est un framework étonnant qui, en plus d'être très accessible, se démarque par un écosystème varié et complet, qui permet d'économiser le développement de fonctionnalités génériques (panneau d'admin, CRUD, gestion des abonnements, authentification, etc.).
L'écosystème Laravel est composé de projets open-source, mais aussi de projets SaaS complets qui peuvent vraiment changer la donne (je suis par exemple tombé amoureux de Laravel Forge), mais est-ce que la France est prête pour le business à l'américaine ?
The Recording HTTP Proxy: Not Yet Another Messiah - Bulgaria PHP 2019Viktor Todorov
In our work we tend to believe in Messiah. A messiah can be the new magic tool which will solve all our problems, or a shiny framework, so much better than everything we have used before, or even a person in our team. We all know the messiah in software testing. It’s the Unit Testing. But is the unit test the one and the only way to test a software? The answer is no. This lecture will show you a new approach to software testing using a Recording HTTP Proxy and how it can help you achieve better quality of your software. Without proclaiming it as “The Great New Messiah”.
The slides from erlounge Wellington 02-2009. Umleintung is a tiny HTTP redirect daemon based on mochiweb and CouchDB.
It describes how to bootstrap a mochiweb application and integrate CouchDB.
CouchDB for Web Applications - Erlang Factory London 2009Jason Davies
CouchDB is built "of the Web" and it's very exciting to convert the immense
power that CouchDB provides into a usable, real-world Web application. In this
talk I cover case studies of real-world applications that use CouchDB,
including some that can be served from CouchDB itself, and how CouchDB can
shape your Web applications to be highly scalable and flexible by embracing
HTTP philosophies, JavaScript and schemaless documents.
Google's Go is a relatively new systems programming language that has recently gained a lot of traction with developers. It brings together the ease and efficiency of development in modern interpreted languages like Python, Perl, and Ruby with the efficiency and safety of a statically typed, compiled language like C/C++ and Java.
On top of that, Go is a language built for modern hardware and problems. With built-in support for concurrency, programmers can easily build software to scale up to today's many-core beasts. Programming in Go is really nice, and in this tutorial, you will learn why.
We will cover an introduction to the Go programming language, and together we will build a multi-user network service demonstrating all of the major principles of programming in Go.
Handling 10k requests per second with Symfony and Varnish - SymfonyCon Berlin...Alexander Lisachenko
It is believed that the Symfony framework is quite heavy and it can be difficult to develop a website that will be able to work under the high load. It is true, but does this mean that it is impossible to implement a dynamic caching and to update only a small part of entire page as data is updated? This talk will give your an answer to that. It is Varnish, ESI-blocks and load balancing. With hundreds of thousands of unique visitors and million hits a day, we continue to use Symfony, and do not see any problems.
Introducing RaveJS: Spring Boot concepts for JavaScript applicationsJohn Hann
Modern JavaScript frameworks have become quite sophisticated. Unfortunately, they have also become quite complicated. The demos and sample projects for these frameworks look deceptively simple. However, to build and deploy real applications, developers must scaffold, configure, and maintain a tremendous amount of intricate machinery. Until recently, the Java world wasn't very different. Spring Boot finally made it easy to create stand-alone, production-grade Spring Applications that can you can "just run". Can we do the same for JavaScript? Yes, we can! Introducing RaveJS. Rave eliminates configuration, machinery, and complexity. Stop configuring and tweaking machinery such as file watchers, minifiers, and transpilers just to get to a runnable app. Instead, go from zero to "hello world" in 30 seconds. In the next 30 seconds, easily add capabilities and frameworks to your application simply by installing *Rave Extensions* and *Rave Starter* packages from npm and Bower, the leading JavaScript package managers. Finally, install additional *Rave Extension* packages to apply your favorite build, deploy, and testing patterns.
Imagine for a while that Rails wouldn't exist. How would we write a MVC app from scratch?
Rack provides a minimal interface for developing web applications in Ruby. In fact it's the solid foundation of all major Ruby powered web frameworks.
During this talk we will dive deep into Rack. We will see the smallest possible Rack Application and learn how it works, by studying Rack internals. We will grow the Application step by step till we implement it in simple MVC style.
Après une douzaine d'années à faire du développement backend sur Symfony, je me retrouve aujourd'hui directeur technique d'une agence qui travaille exclusivement sur Laravel, quel choc !
En France quand on parle de Laravel, le débat tourne vite au troll (parce que Symfony = cocorico, donc Laravel forcément = satan). Mais loin des clichés Laravel est un framework étonnant qui, en plus d'être très accessible, se démarque par un écosystème varié et complet, qui permet d'économiser le développement de fonctionnalités génériques (panneau d'admin, CRUD, gestion des abonnements, authentification, etc.).
L'écosystème Laravel est composé de projets open-source, mais aussi de projets SaaS complets qui peuvent vraiment changer la donne (je suis par exemple tombé amoureux de Laravel Forge), mais est-ce que la France est prête pour le business à l'américaine ?
The Recording HTTP Proxy: Not Yet Another Messiah - Bulgaria PHP 2019Viktor Todorov
In our work we tend to believe in Messiah. A messiah can be the new magic tool which will solve all our problems, or a shiny framework, so much better than everything we have used before, or even a person in our team. We all know the messiah in software testing. It’s the Unit Testing. But is the unit test the one and the only way to test a software? The answer is no. This lecture will show you a new approach to software testing using a Recording HTTP Proxy and how it can help you achieve better quality of your software. Without proclaiming it as “The Great New Messiah”.
The slides from erlounge Wellington 02-2009. Umleintung is a tiny HTTP redirect daemon based on mochiweb and CouchDB.
It describes how to bootstrap a mochiweb application and integrate CouchDB.
PHP Data Objects (PDO) provides a clear, simple (but powerful), unified API for working with all our favorite databases. Features include prepared statements with bound parameters (for all databases, even those that don’t natively support them), transactions, cursors, LOBs, and flexible error handling.
PECL Picks - Extensions to make your life betterZendCon
One of the biggest strengths of PHP is its "glue" power. Take any C library and with a little magic and a compiler you have a fantastic extension. These extensions hide in PECL, but few people can tell the good from the unmaintained or just plain broken. Find the best extensions for your project, learn about PECL, and find out how to become a part of the PECL developer community.
Hiveminder - Everything but the Secret SauceJesse Vincent
Ten tools and techniques to help you:
Find bugs faster バグの検出をもっと素早く
Build web apps ウェブアプリの構築
Ship software ソフトのリリース
Get input from users ユーザからの入力を受けつける
Own the Inbox 受信箱を用意する
今日の話
Slides from presentation: "Revoke-Obfuscation: PowerShell Obfuscation Detection (And Evasion) Using Science" originally released at Black Hat USA 2017 & DEF CON by @danielhbohannon and @Lee_Holmes.
For more information: http://www.danielbohannon.com/presentations/
From our "PHP Open Day" - Tal Tamir's lacture.
Today, every simple application requires working with databases. The lecture was intended to show a simple and effective way to work in PHP with DB's
Given at zendcon 2008 - my very first conference talk. And I did it way too fast. A lot of the information about these extensions is surprisingly relevant.
Implicitly or explicitly all competing businesses employ a strategy to select a mix
of marketing resources. Formulating such competitive strategies fundamentally
involves recognizing relationships between elements of the marketing mix (e.g.,
price and product quality), as well as assessing competitive and market conditions
(i.e., industry structure in the language of economics).
Discover the innovative and creative projects that highlight my journey throu...dylandmeas
Discover the innovative and creative projects that highlight my journey through Full Sail University. Below, you’ll find a collection of my work showcasing my skills and expertise in digital marketing, event planning, and media production.
Kseniya Leshchenko: Shared development support service model as the way to ma...Lviv Startup Club
Kseniya Leshchenko: Shared development support service model as the way to make small projects with small budgets profitable for the company (UA)
Kyiv PMDay 2024 Summer
Website – www.pmday.org
Youtube – https://www.youtube.com/startuplviv
FB – https://www.facebook.com/pmdayconference
Digital Transformation and IT Strategy Toolkit and TemplatesAurelien Domont, MBA
This Digital Transformation and IT Strategy Toolkit was created by ex-McKinsey, Deloitte and BCG Management Consultants, after more than 5,000 hours of work. It is considered the world's best & most comprehensive Digital Transformation and IT Strategy Toolkit. It includes all the Frameworks, Best Practices & Templates required to successfully undertake the Digital Transformation of your organization and define a robust IT Strategy.
Editable Toolkit to help you reuse our content: 700 Powerpoint slides | 35 Excel sheets | 84 minutes of Video training
This PowerPoint presentation is only a small preview of our Toolkits. For more details, visit www.domontconsulting.com
Skye Residences | Extended Stay Residences Near Toronto Airportmarketingjdass
Experience unparalleled EXTENDED STAY and comfort at Skye Residences located just minutes from Toronto Airport. Discover sophisticated accommodations tailored for discerning travelers.
Website Link :
https://skyeresidences.com/
https://skyeresidences.com/about-us/
https://skyeresidences.com/gallery/
https://skyeresidences.com/rooms/
https://skyeresidences.com/near-by-attractions/
https://skyeresidences.com/commute/
https://skyeresidences.com/contact/
https://skyeresidences.com/queen-suite-with-sofa-bed/
https://skyeresidences.com/queen-suite-with-sofa-bed-and-balcony/
https://skyeresidences.com/queen-suite-with-sofa-bed-accessible/
https://skyeresidences.com/2-bedroom-deluxe-queen-suite-with-sofa-bed/
https://skyeresidences.com/2-bedroom-deluxe-king-queen-suite-with-sofa-bed/
https://skyeresidences.com/2-bedroom-deluxe-queen-suite-with-sofa-bed-accessible/
#Skye Residences Etobicoke, #Skye Residences Near Toronto Airport, #Skye Residences Toronto, #Skye Hotel Toronto, #Skye Hotel Near Toronto Airport, #Hotel Near Toronto Airport, #Near Toronto Airport Accommodation, #Suites Near Toronto Airport, #Etobicoke Suites Near Airport, #Hotel Near Toronto Pearson International Airport, #Toronto Airport Suite Rentals, #Pearson Airport Hotel Suites
The world of search engine optimization (SEO) is buzzing with discussions after Google confirmed that around 2,500 leaked internal documents related to its Search feature are indeed authentic. The revelation has sparked significant concerns within the SEO community. The leaked documents were initially reported by SEO experts Rand Fishkin and Mike King, igniting widespread analysis and discourse. For More Info:- https://news.arihantwebtech.com/search-disrupted-googles-leaked-documents-rock-the-seo-world/
Attending a job Interview for B1 and B2 Englsih learnersErika906060
It is a sample of an interview for a business english class for pre-intermediate and intermediate english students with emphasis on the speking ability.
LA HUG - Video Testimonials with Chynna Morgan - June 2024Lital Barkan
Have you ever heard that user-generated content or video testimonials can take your brand to the next level? We will explore how you can effectively use video testimonials to leverage and boost your sales, content strategy, and increase your CRM data.🤯
We will dig deeper into:
1. How to capture video testimonials that convert from your audience 🎥
2. How to leverage your testimonials to boost your sales 💲
3. How you can capture more CRM data to understand your audience better through video testimonials. 📊
RMD24 | Retail media: hoe zet je dit in als je geen AH of Unilever bent? Heid...BBPMedia1
Grote partijen zijn al een tijdje onderweg met retail media. Ondertussen worden in dit domein ook de kansen zichtbaar voor andere spelers in de markt. Maar met die kansen ontstaan ook vragen: Zelf retail media worden of erop adverteren? In welke fase van de funnel past het en hoe integreer je het in een mediaplan? Wat is nu precies het verschil met marketplaces en Programmatic ads? In dit half uur beslechten we de dilemma's en krijg je antwoorden op wanneer het voor jou tijd is om de volgende stap te zetten.
Premium MEAN Stack Development Solutions for Modern BusinessesSynapseIndia
Stay ahead of the curve with our premium MEAN Stack Development Solutions. Our expert developers utilize MongoDB, Express.js, AngularJS, and Node.js to create modern and responsive web applications. Trust us for cutting-edge solutions that drive your business growth and success.
Know more: https://www.synapseindia.com/technology/mean-stack-development-company.html
Unveiling the Secrets How Does Generative AI Work.pdfSam H
At its core, generative artificial intelligence relies on the concept of generative models, which serve as engines that churn out entirely new data resembling their training data. It is like a sculptor who has studied so many forms found in nature and then uses this knowledge to create sculptures from his imagination that have never been seen before anywhere else. If taken to cyberspace, gans work almost the same way.
RMD24 | Debunking the non-endemic revenue myth Marvin Vacquier Droop | First ...BBPMedia1
Marvin neemt je in deze presentatie mee in de voordelen van non-endemic advertising op retail media netwerken. Hij brengt ook de uitdagingen in beeld die de markt op dit moment heeft op het gebied van retail media voor niet-leveranciers.
Retail media wordt gezien als het nieuwe advertising-medium en ook mediabureaus richten massaal retail media-afdelingen op. Merken die niet in de betreffende winkel liggen staan ook nog niet in de rij om op de retail media netwerken te adverteren. Marvin belicht de uitdagingen die er zijn om echt aansluiting te vinden op die markt van non-endemic advertising.
Business Valuation Principles for EntrepreneursBen Wann
This insightful presentation is designed to equip entrepreneurs with the essential knowledge and tools needed to accurately value their businesses. Understanding business valuation is crucial for making informed decisions, whether you're seeking investment, planning to sell, or simply want to gauge your company's worth.
2. we're hiring:
http://omniti.com/people/jobs
About the author
• PHP Core Developer since 2001
• Author of the Streams layer
• “King” of PECL
• Author of most of PDO and its drivers
• Day‐job is developing the Fastest MTA on
Earth
3. we're hiring:
http://omniti.com/people/jobs
Coming up…
• Problems with PHP DB access
• PDO Solution
• Features / Drivers
• Installation
• Getting Started
• Features
4. we're hiring:
http://omniti.com/people/jobs
The Problem
• No consistency of API between DB extensions
• Sometimes no self‐consistency within a given
extension
• Duplicated code (but not)
• High maintenance
5. we're hiring:
http://omniti.com/people/jobs
The PDO Solution
• Move PHP specific stuff into one extension
• Database specific stuff (only) in their own
extensions
• Data access abstraction, not database
abstraction
6. we're hiring:
http://omniti.com/people/jobs
Features
Performance
• Native C code beats a scripted solution
• Takes advantage of latest PHP 5 internals
7. we're hiring:
http://omniti.com/people/jobs
Features
Power
• Gives you common DB features as a base
• Still be able to access specialist functions
8. we're hiring:
http://omniti.com/people/jobs
What can it do?
• Prepare/execute, bound parameters
• Transactions
• LOBS
• Scrollable Cursors
• SQLSTATE error codes, flexible error handling
• Portability attributes
9. we're hiring:
http://omniti.com/people/jobs
Available Drivers
• Pretty much all of them:
• MySQL, PostgreSQL
• ODBC, DB2, OCI
• SQLite (2 and 3)
• Sybase/FreeTDS/MSSQL
• Firebird (needs love)
10. we're hiring:
http://omniti.com/people/jobs
Installing
• Ships with PHP 5.1
• Available for PHP 5.0.x via PECL
• DLLs downloadable for both on Windows via
http://pecl4win.php.net
11. we're hiring:
http://omniti.com/people/jobs
Building w/ PHP 5.0
./configure
‐‐with‐zlib
‐‐prefix=/usr/local/php5
• pear upgrade pear
• pear install PDO
• extension=pdo.so in your php.ini
12. we're hiring:
http://omniti.com/people/jobs
Building w/ PHP 5.0
• Select the driver(s) you need
• pear install PDO_XXX
• extension=pdo_xxx.so in your php.ini
13. we're hiring:
http://omniti.com/people/jobs
Installing on Win32
• Grab the DLLs from the snaps site
http://pecl4win.php.net/
• You need:
– php_pdo.dll
– php_pdo_XXX.dll
• Put them in C:php5ext
14. we're hiring:
http://omniti.com/people/jobs
Switching it on
• Need to enable PDO in your php.ini
• MUST load PDO first
• Unix:
– extension=pdo.so
– extension=pdo_XXX.so
• Windows:
– extension=php_pdo.dll
– extension=php_pdo_XXX.dll
15. we're hiring:
http://omniti.com/people/jobs
Connecting via PDO
try {
$dbh = new PDO($dsn, $user,
$password, $options);
} catch (PDOException $e) {
echo ”Failed to connect:”
. $e‐>getMessage();
}
16. we're hiring:
http://omniti.com/people/jobs
DSNs
• In general
drivername:<driver‐specific‐stuff>
19. we're hiring:
http://omniti.com/people/jobs
DSN Aliasing
• uri:uri
– Specify location of a file containing actual DSN on
the first line
– Works with streams interface, so remote URLs can
work too
• name (with no colon)
– Maps to pdo.dsn.name in your php.ini
– pdo.dsn.name=sqlite:/path/to/name.db
20. we're hiring:
http://omniti.com/people/jobs
DSN Aliasing
• pdo.dsn.name=sqlite:/path/to/name.db
$dbh = new PDO(quot;namequot;);
Same as:
$dbh = new PDO(quot;sqlite:/path/to/name.dbquot;);
21. we're hiring:
http://omniti.com/people/jobs
Connection Management
try {
$dbh = new PDO($dsn, $user, $pw);
// use the database here
// ...
// done; release the connection
$dbh = null;
} catch (PDOException $e) {
echo ”connect failed:”
. $e‐>getMessage();
}
23. we're hiring:
http://omniti.com/people/jobs
Persistent PDO
• Can specify your own cache key
$dbh = new PDO($dsn, $user, $pass,
array(
PDO::ATTR_PERSISTENT => “my‐key”
)
);
• Useful for keeping separate persistent connections
24. we're hiring:
http://omniti.com/people/jobs
Persistent PDO
• The ODBC driver runs with connection pooling
enabled by default
• “better” than PHP‐level persistence
– Pool is shared at the process level
• Can be forced off by setting
– pdo_odbc.connection_pooling=off
25. we're hiring:
http://omniti.com/people/jobs
Let’s get data
$dbh = new PDO($dsn);
$stmt = $dbh‐>prepare(
quot;SELECT * FROM FOOquot;);
$stmt‐>execute();
while ($row = $stmt‐>fetch()) {
print_r($row);
}
$stmt = null;
26. we're hiring:
http://omniti.com/people/jobs
Forward‐only cursors
• Also known as quot;unbufferedquot; queries in mysql
parlance
• They are the default cursor type
• rowCount() doesn't have meaning
• FAST!
27. we're hiring:
http://omniti.com/people/jobs
Forward‐only cursors
• Other queries are likely to block
• You must fetch all remaining data before
launching another query
• $stmt‐>closeCursor()
29. we're hiring:
http://omniti.com/people/jobs
Data typing
• Very loose
• uses strings for data
• Gives you more control over data conversion
• Supports integers where 1:1 mapping exists
• Is float agnostic
– PDO is precise
30. we're hiring:
http://omniti.com/people/jobs
Fetch modes
• $stmt‐>fetch(PDO::FETCH_BOTH)
– Array with numeric and string keys
– default option
• PDO::FETCH_NUM
– Numeric only
• PDO::FETCH_ASSOC
– String only
31. we're hiring:
http://omniti.com/people/jobs
Fetch modes
• PDO::FETCH_OBJ
– stdClass object
– $obj‐>name == ‘name’ column
• PDO::FETCH_CLASS
– You choose the class
• PDO::FETCH_INTO
– You provide the object
32. we're hiring:
http://omniti.com/people/jobs
Fetch modes
• PDO::FETCH_COLUMN
– Fetches only a particular column
• PDO::FETCH_BOUND
– Only fetches into bound variables
• PDO::FETCH_FUNC
– Returns the result of a callback
• and more…
33. we're hiring:
http://omniti.com/people/jobs
Iterators
$dbh = new PDO($dsn);
$stmt = $dbh‐>query(
quot;SELECT name FROM FOOquot;,
PDO::FETCH_COLUMN, 0);
foreach ($stmt as $name) {
echo quot;Name: $namenquot;;
}
$stmt = null;
34. we're hiring:
http://omniti.com/people/jobs
Changing data
$deleted = $dbh‐>exec(
quot;DELETE FROM FOO WHERE 1quot;);
$changes = $dbh‐>exec(
quot;UPDATE FOO SET active=1 quot;
. quot;WHERE NAME LIKE '%joe%'quot;);
35. we're hiring:
http://omniti.com/people/jobs
Autonumber/sequences
$dbh‐>exec(
quot;insert into foo values (...)quot;);
echo $dbh‐>lastInsertId();
$dbh‐>exec(
quot;insert into foo values (...)quot;);
echo $dbh‐>lastInsertId(“seqname”);
It’s up to you to call it appropriately
36. we're hiring:
http://omniti.com/people/jobs
Smarter queries
• Quoting is annoying, but essential
• PDO offers a better way
$stmt = $db‐>prepare(“INSERT INTO CREDITS ”
.“(extension, name) ”
.“VALUES (:extension, :name)”);
$stmt‐>execute(array(
'extension' => 'xdebug',
'name' => 'Derick Rethans'
));
37. we're hiring:
http://omniti.com/people/jobs
Smarter queries
• Quoting is annoying, but essential
• PDO offers a better way
$stmt = $db‐>prepare(“INSERT INTO CREDITS ”
.“(extension, name) ”
.“VALUES (?, ?)”);
$stmt‐>execute(array(
'xdebug',
'Derick Rethans'
));
38. we're hiring:
http://omniti.com/people/jobs
$db‐>quote()
• If you still need to quote things “by‐hand”
• Currently a no‐op for the ODBC driver
42. we're hiring:
http://omniti.com/people/jobs
Binding columns for output
$stmt = $dbh‐>prepare(
quot;SELECT extension, name from CREDITSquot;);
if ($stmt‐>execute()) {
$stmt‐>bindColumn('extension', $extension);
$stmt‐>bindColumn('name', $name);
while ($stmt‐>fetch(PDO::FETCH_BOUND)) {
echo quot;Extension: $extensionnquot;;
echo quot;Author: $namenquot;;
}
}
43. we're hiring:
http://omniti.com/people/jobs
Portability Aids
• PDO aims to make it easier to write db
independent apps
• Number of hacks^Wtweaks for this purpose
44. we're hiring:
http://omniti.com/people/jobs
Oracle style NULLs
• Oracle translates empty strings into NULLs
• $dbh‐>setAttribute(PDO::ATTR_ORACLE_NULLS, true);
• Translates empty strings into NULLs when
fetching data
• But won’t change them on insert
45. we're hiring:
http://omniti.com/people/jobs
Case folding
• The ANSI SQL standard says that column
names are returned in upper case
• High end databases (eg: Oracle and DB2)
respect this
• Most others don’t
$dbh‐>setAttribute(
PDO::ATTR_CASE,
PDO::CASE_UPPER);
46. we're hiring:
http://omniti.com/people/jobs
Error Handling
• PDO offers 3 different error modes
• $dbh‐>setAttribute(PDO_ATTR_ERRMODE,
$mode);
– PDO::ERRMODE_SILENT
– PDO::ERRMODE_WARNING
– PDO::ERRMODE_EXCEPTION
• Attempts to map native codes to SQLSTATE
standard codes
• But still offers native info too
47. we're hiring:
http://omniti.com/people/jobs
PDO::ERRMODE_SILENT
if (!$dbh‐>query($sql)) {
echo $dbh‐>errorCode() . quot;<br>quot;;
$info = $dbh‐>errorInfo();
// $info[0] == $dbh‐>errorCode()
// SQLSTATE error code
// $info[1] is the driver specific
// error code
// $info[2] is the driver specific
// error string
}
48. we're hiring:
http://omniti.com/people/jobs
PDO::ERRMODE_WARNING
• Same as PDO::ERRMODE_SILENT
• But, raises an E_WARNING as errors are
detected
• You can selectively suppress the warnings
with @ operator
49. we're hiring:
http://omniti.com/people/jobs
PDO_ERRMODE_EXCEPTION
try {
$dbh‐>exec($sql);
} catch (PDOException $e) {
// display warning message print
$e‐>getMessage();
$info = $e‐>errorInfo;
// $info[0] == $e‐>code;
// SQLSTATE error code
// $info[1] is the driver specific error code
// $info[2] is the driver specific error string
}
51. we're hiring:
http://omniti.com/people/jobs
LOBs via Streams
• Large objects are usually 4kb or more in size
• Advantageous to avoid fetching them until
you really need to
• Mature RDBMS offer LOB APIs for this
• PDO exposes LOBS as Streams
52. we're hiring:
http://omniti.com/people/jobs
Fetching an image
$db = new PDO($dsn);
$stmt = $db‐>prepare(
“select contenttype, imagedata”
.“ from images where id=?”);
$stmt‐>execute(array($_GET['id']));
$stmt‐>bindColumn(1, $type, PDO::PARAM_STR,
256);
$stmt‐>bindColumn(2, $lob, PDO::PARAM_LOB);
$stmt‐>fetch(PDO::FETCH_BOUND);
header(quot;Content‐Type: $typequot;);
fpassthru($lob);
54. we're hiring:
http://omniti.com/people/jobs
Scrollable Cursors
• Allow random access to a rowset
• Higher resource usage than forward‐only
cursors
• Can be used to emulate limit, offset style
paged queries
• Can be used for positioned updates (more
useful for CLI/GUI apps)
55. we're hiring:
http://omniti.com/people/jobs
Positioned updates
• An open (scrollable) cursor can be used to
target a row for another query
• Name your cursor by setting
PDO::ATTR_CURSOR_NAME during prepare()
• UPDATE foo set bar = ? WHERE
CURRENT OF cursor_name
57. we're hiring:
http://omniti.com/people/jobs
Questions?
• These slides:
– http://omniti.com/resources/talks
• Gold:
– http://troels.arvin.dk/db/rdbms/#select‐limit‐offset
• Publications
– google for “wez furlong pdo db2”
– google for “wez furlong pdo oci”
• My blog: http://netevil.org
• We’re hiring: we have positions open for
– PHP, Perl and C developers
– a security analyst
– http://omniti.com/people/jobs