SlideShare a Scribd company logo
PHP Data Objects Layer (PDO) Ilia Alshanetsky
What is PDO ,[object Object],[object Object],[object Object]
Why is it needed? ,[object Object],[object Object],[object Object],[object Object],[object Object]
What Databases are Supported? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Installing PDO ,[object Object],[object Object],[object Object],[object Object],[object Object]
Actual Install Steps ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Using PDO ,[object Object],// MySQL connection new PDO(‘mysql:host=localhost;dbname=testdb’, $login, $passwd); // PostgreSQL new PDO(‘pgsql:host=localhost port=5432 dbname=testdb user=john password=mypass’); // SQLite new PDO(‘sqlite:/path/to/database_file’);
What if the Connection Fails? ,[object Object],try { $db = new PDO(…); } catch (PDOException $e) { echo $e->getMessage(); }
Persistent Connections ,[object Object],$opt =  array(PDO::ATTR_PERSISTENT => TRUE)  ; try { $db = new PDO(“dsn”,  $l,  $p,  $opt); } catch (PDOException $e) { echo $e->getMessage(); }
DSN INI Tricks ,[object Object],ini_set(“pdo.dsn.ilia”, “sqlite::memory”); try { $db = new PDO(“ilia”); } catch (PDOException $e) { echo $e->getMessage(); }
Let’s Run Some Queries ,[object Object],[object Object],[object Object]
Direct Query Execution ,[object Object],[object Object],$db = new PDO(“DSN”); $db->exec(“INSERT INTO foo (id) VALUES(‘bar’)”); $db->exec(“UPDATE foo SET id=‘bar’”);
Direct Query Execution Cont. ,[object Object],$res = $db->exec(“UPDATE foo SET id=‘bar’”); if (!$res)  // Wrong if ($res !== FALSE)  // Correct
Retrieving Error Information ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Better Error Handling ,[object Object],[object Object],$db->setAttribute( PDO::ATTR_ERRMODE ,  PDO::ERRMODE_EXCEPTION   );
Direct Execution Cont. ,[object Object],[object Object],$res = $db->query(“SELECT * FROM foo”); // $res == PDOStatement Object
Fetch Query Results ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Array Fetching $res = $db->query(“SELECT * FROM foo”); while ($row = $res->fetch(PDO::FETCH_NUM)){ // $row == array with numeric keys } $res = $db->query(“SELECT * FROM foo”); while ($row = $res->fetch(PDO::FETCH_ASSOC)){ // $row == array with associated (string) keys } $res = $db->query(“SELECT * FROM foo”); while ($row = $res->fetch(PDO::FETCH_BOTH)){ // $row == array with associated & numeric keys }
Fetch as String ,[object Object],$u = $db->query(“SELECT users WHERE login=‘login’ AND password=‘password’”); // fetch(PDO::FETCH_COLUMN) if ($u->fetchColumn()) {  // returns a string // login OK } else {  /* authentication failure */  }
Fetch as Standard Object ,[object Object],$res = $db->query(“SELECT * FROM foo”); while ($obj = $res->fetch(PDO::FETCH_OBJ)) { // $obj == instance of stdClass }
Fetch Into a Class ,[object Object],$res = $db->query(“SELECT * FROM foo”); $res->setFetchMode( PDO::FETCH_CLASS, “ className”, array(‘optional’=‘Constructor Params’) ); while ($obj = $res->fetch()) { // $obj == instance of className }
Fetch Into a Class Cont. ,[object Object],$res = $db->query(“SELECT * FROM foo”); $res->setFetchMode( PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE ); while ($obj = $res->fetch()) { // $obj == instance of class who’s name is // found in the value of the 1 st  column }
Fetch Into an Object ,[object Object],$u = new userObject; $res = $db->query(“SELECT * FROM users”); $res->setFetchMode(PDO::FETCH_INTO, $u);  while ($res->fetch()) { // will re-populate $u with row values }
Result Iteration ,[object Object],$res = $db->query( “ SELECT * FROM users”,  PDO::FETCH_ASSOC ); foreach ($res as $row) { // $row == associated array representing // the row’s values. }
Lazy Fetching ,[object Object],$res = $db->query( “ SELECT * FROM users”,  PDO::FETCH_LAZY ); foreach ($res as $row) { echo $row[‘name’];  // only fetch name column }
fetchAll() ,[object Object],[object Object],$qry = “SELECT * FROM users”; $res = $db->query($qry)->fetchAll( PDO::FETCH_ASSOC ); // $res == array of all result rows, where each row // is an associated array.
Callback Function ,[object Object],function draw_message($subject,$email) { … } $res = $db->query(“SELECT * FROM msg”); $res->fetchAll( PDO::FETCH_FUNC,  “ draw_message” );
Direct Query Problems ,[object Object],[object Object]
Escaping in PDO ,[object Object],$qry = “SELECT * FROM users WHERE  login=“.$db->quote($_POST[‘login’]).” AND passwd=“.$db->quote($_POST[‘pass’]);
Prepared Statements ,[object Object],[object Object],[object Object]
Prepared Statements in Action $stmt = $db->prepare( “ SELECT * FROM users WHERE id=?” ); $stmt->execute(array($_GET[‘id’])); $stmt->fetch(PDO::FETCH_ASSOC);
Bound Parameters ,[object Object],$stmt = $db->prepare( “ INSERT INTO users VALUES(:name,:pass,:mail)”); foreach (array(‘name’,’pass’,’mail’) as $v)  $stmt->bindParam(‘:’.$v,$$v); $fp = fopen(“./users”, “r”); while (list($name,$pass,$mail) = fgetcsv($fp,4096)) { $stmt->execute(); }
Bound Result Columns ,[object Object],$qry = “SELECT :type, :data FROM images LIMIT 1”; $stmt = $db->prepare($qry); $stmt->bindColumn(‘:type’,$type); $stmt->bindColumn(‘:type’,STDOUT,PDO::PARAM_LOB); $stmt->execute(PDO::FETCH_BOUND); header(“Content-Type: “.$type);
Partial Data Retrieval ,[object Object],$res = $db->query(“SELECT * FROM users”); foreach ($res as $v) { if ($res[‘name’] == ‘end’) { $res->closeCursor(); break; } }
Transactions ,[object Object],$db->beginTransaction(); if ($db->exec($qry) === FALSE) { $db->rollback(); } $db->commit();
Metadata ,[object Object],$res = $db->query($qry); $ncols = $res->columnCount(); for ($i=0; $i < $ncols; $i++) { $meta_data = $stmt->getColumnMeta($i); }
getColumnMeta() Result ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
lastInsertId() ,[object Object],[object Object],[object Object],if ($db->exec(“INSERT INTO …”)) { $id = $db->lastInsertId(); }
Connection Information ,[object Object],$db->getAttribute(PDO::ATTR_SERVER_VERSION); // Database Server Version $db->getAttribute(PDO::ATTR_CLIENT_VERSION); // Client Library Server Version $db->getAttribute(PDO::ATTR_SERVER_INFO); // Misc Server information $db->getAttribute(PDO::ATTR_CONNECTION_STATUS); // Connection Status
Extending PDO ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Questions

More Related Content

What's hot

Adodb Pdo Presentation
Adodb Pdo PresentationAdodb Pdo Presentation
Adodb Pdo Presentation
Tom Rogers
 
international PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretsinternational PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretssmueller_sandsmedia
 
New in cakephp3
New in cakephp3New in cakephp3
New in cakephp3
markstory
 
Advanced Querying with CakePHP 3
Advanced Querying with CakePHP 3Advanced Querying with CakePHP 3
Advanced Querying with CakePHP 3
José Lorenzo Rodríguez Urdaneta
 
Doctrine 2
Doctrine 2Doctrine 2
Doctrine 2
zfconfua
 
CakeFest 2013 keynote
CakeFest 2013 keynoteCakeFest 2013 keynote
CakeFest 2013 keynote
José Lorenzo Rodríguez Urdaneta
 
Internationalizing CakePHP Applications
Internationalizing CakePHP ApplicationsInternationalizing CakePHP Applications
Internationalizing CakePHP Applications
Pierre MARTIN
 
Php tips-and-tricks4128
Php tips-and-tricks4128Php tips-and-tricks4128
Php tips-and-tricks4128PrinceGuru MS
 
The Origin of Lithium
The Origin of LithiumThe Origin of Lithium
The Origin of Lithium
Nate Abele
 
Php unit the-mostunknownparts
Php unit the-mostunknownpartsPhp unit the-mostunknownparts
Php unit the-mostunknownparts
Bastian Feder
 
Introducing PHP Data Objects
Introducing PHP Data ObjectsIntroducing PHP Data Objects
Introducing PHP Data Objectswebhostingguy
 
Advanced php testing in action
Advanced php testing in actionAdvanced php testing in action
Advanced php testing in action
Jace Ju
 
Dependency Injection with PHP and PHP 5.3
Dependency Injection with PHP and PHP 5.3Dependency Injection with PHP and PHP 5.3
Dependency Injection with PHP and PHP 5.3Fabien Potencier
 
The Zen of Lithium
The Zen of LithiumThe Zen of Lithium
The Zen of Lithium
Nate Abele
 
Lithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate FrameworksLithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate Frameworks
Nate Abele
 
PHP Data Objects
PHP Data ObjectsPHP Data Objects
PHP Data Objects
Prashant Marathe
 
Web 11 | AJAX + JSON + PHP
Web 11 | AJAX + JSON + PHPWeb 11 | AJAX + JSON + PHP
Web 11 | AJAX + JSON + PHP
Mohammad Imam Hossain
 
PHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolvePHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolve
XSolve
 
SPL: The Missing Link in Development
SPL: The Missing Link in DevelopmentSPL: The Missing Link in Development
SPL: The Missing Link in Developmentjsmith92
 

What's hot (20)

Adodb Pdo Presentation
Adodb Pdo PresentationAdodb Pdo Presentation
Adodb Pdo Presentation
 
international PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secretsinternational PHP2011_Bastian Feder_jQuery's Secrets
international PHP2011_Bastian Feder_jQuery's Secrets
 
New in cakephp3
New in cakephp3New in cakephp3
New in cakephp3
 
Advanced Querying with CakePHP 3
Advanced Querying with CakePHP 3Advanced Querying with CakePHP 3
Advanced Querying with CakePHP 3
 
Doctrine 2
Doctrine 2Doctrine 2
Doctrine 2
 
jQuery secrets
jQuery secretsjQuery secrets
jQuery secrets
 
CakeFest 2013 keynote
CakeFest 2013 keynoteCakeFest 2013 keynote
CakeFest 2013 keynote
 
Internationalizing CakePHP Applications
Internationalizing CakePHP ApplicationsInternationalizing CakePHP Applications
Internationalizing CakePHP Applications
 
Php tips-and-tricks4128
Php tips-and-tricks4128Php tips-and-tricks4128
Php tips-and-tricks4128
 
The Origin of Lithium
The Origin of LithiumThe Origin of Lithium
The Origin of Lithium
 
Php unit the-mostunknownparts
Php unit the-mostunknownpartsPhp unit the-mostunknownparts
Php unit the-mostunknownparts
 
Introducing PHP Data Objects
Introducing PHP Data ObjectsIntroducing PHP Data Objects
Introducing PHP Data Objects
 
Advanced php testing in action
Advanced php testing in actionAdvanced php testing in action
Advanced php testing in action
 
Dependency Injection with PHP and PHP 5.3
Dependency Injection with PHP and PHP 5.3Dependency Injection with PHP and PHP 5.3
Dependency Injection with PHP and PHP 5.3
 
The Zen of Lithium
The Zen of LithiumThe Zen of Lithium
The Zen of Lithium
 
Lithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate FrameworksLithium: The Framework for People Who Hate Frameworks
Lithium: The Framework for People Who Hate Frameworks
 
PHP Data Objects
PHP Data ObjectsPHP Data Objects
PHP Data Objects
 
Web 11 | AJAX + JSON + PHP
Web 11 | AJAX + JSON + PHPWeb 11 | AJAX + JSON + PHP
Web 11 | AJAX + JSON + PHP
 
PHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolvePHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolve
 
SPL: The Missing Link in Development
SPL: The Missing Link in DevelopmentSPL: The Missing Link in Development
SPL: The Missing Link in Development
 

Viewers also liked

Kali linux
Kali linuxKali linux
Kali linux
BGA Cyber Security
 
pfSense Firewall ve Router Eğitimi
pfSense Firewall ve Router EğitimipfSense Firewall ve Router Eğitimi
pfSense Firewall ve Router EğitimiBGA Cyber Security
 
Beyaz Şapkalı Hacker (CEH) Lab Kitabı
Beyaz Şapkalı Hacker (CEH) Lab KitabıBeyaz Şapkalı Hacker (CEH) Lab Kitabı
Beyaz Şapkalı Hacker (CEH) Lab Kitabı
BGA Cyber Security
 
Kali ile Linux'e Giriş | IntelRAD
Kali ile Linux'e Giriş | IntelRADKali ile Linux'e Giriş | IntelRAD
Kali ile Linux'e Giriş | IntelRAD
Mehmet Ince
 
Beyaz Şapkalı Hacker CEH Eğitimi - Bölüm 1, 2, 3
Beyaz Şapkalı Hacker CEH Eğitimi - Bölüm 1, 2, 3Beyaz Şapkalı Hacker CEH Eğitimi - Bölüm 1, 2, 3
Beyaz Şapkalı Hacker CEH Eğitimi - Bölüm 1, 2, 3
BGA Cyber Security
 
Linux 4.x Tracing: Performance Analysis with bcc/BPF
Linux 4.x Tracing: Performance Analysis with bcc/BPFLinux 4.x Tracing: Performance Analysis with bcc/BPF
Linux 4.x Tracing: Performance Analysis with bcc/BPF
Brendan Gregg
 

Viewers also liked (9)

PHP OOP
PHP OOPPHP OOP
PHP OOP
 
Kali linux
Kali linuxKali linux
Kali linux
 
BGA Eğitim Sunum
BGA Eğitim SunumBGA Eğitim Sunum
BGA Eğitim Sunum
 
pfSense Firewall ve Router Eğitimi
pfSense Firewall ve Router EğitimipfSense Firewall ve Router Eğitimi
pfSense Firewall ve Router Eğitimi
 
Beyaz Şapkalı Hacker (CEH) Lab Kitabı
Beyaz Şapkalı Hacker (CEH) Lab KitabıBeyaz Şapkalı Hacker (CEH) Lab Kitabı
Beyaz Şapkalı Hacker (CEH) Lab Kitabı
 
Kali ile Linux'e Giriş | IntelRAD
Kali ile Linux'e Giriş | IntelRADKali ile Linux'e Giriş | IntelRAD
Kali ile Linux'e Giriş | IntelRAD
 
Php mysql ppt
Php mysql pptPhp mysql ppt
Php mysql ppt
 
Beyaz Şapkalı Hacker CEH Eğitimi - Bölüm 1, 2, 3
Beyaz Şapkalı Hacker CEH Eğitimi - Bölüm 1, 2, 3Beyaz Şapkalı Hacker CEH Eğitimi - Bölüm 1, 2, 3
Beyaz Şapkalı Hacker CEH Eğitimi - Bölüm 1, 2, 3
 
Linux 4.x Tracing: Performance Analysis with bcc/BPF
Linux 4.x Tracing: Performance Analysis with bcc/BPFLinux 4.x Tracing: Performance Analysis with bcc/BPF
Linux 4.x Tracing: Performance Analysis with bcc/BPF
 

Similar to Quebec pdo

Working with databases in Perl
Working with databases in PerlWorking with databases in Perl
Working with databases in Perl
Laurent Dami
 
PHP CLI: A Cinderella Story
PHP CLI: A Cinderella StoryPHP CLI: A Cinderella Story
PHP CLI: A Cinderella Story
Mike Lively
 
Introducing PHP Latest Updates
Introducing PHP Latest UpdatesIntroducing PHP Latest Updates
Introducing PHP Latest UpdatesIftekhar Eather
 
Php Data Objects
Php Data ObjectsPhp Data Objects
Php Data Objectshiren.joshi
 
Zend framework 03 - singleton factory data mapper caching logging
Zend framework 03 - singleton factory data mapper caching loggingZend framework 03 - singleton factory data mapper caching logging
Zend framework 03 - singleton factory data mapper caching logging
Tricode (part of Dept)
 
Fatc
FatcFatc
Porting Applications From Oracle To PostgreSQL
Porting Applications From Oracle To PostgreSQLPorting Applications From Oracle To PostgreSQL
Porting Applications From Oracle To PostgreSQL
Peter Eisentraut
 
Debugging: Rules & Tools
Debugging: Rules & ToolsDebugging: Rules & Tools
Debugging: Rules & Tools
Ian Barber
 
Doctrine and NoSQL
Doctrine and NoSQLDoctrine and NoSQL
Doctrine and NoSQL
Benjamin Eberlei
 
Perforce Object and Record Model
Perforce Object and Record Model  Perforce Object and Record Model
Perforce Object and Record Model
Perforce
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applications
chartjes
 
Xml Java
Xml JavaXml Java
Xml Javacbee48
 
Jeff Channell - Secure PHP Coding Practices
Jeff Channell - Secure PHP Coding PracticesJeff Channell - Secure PHP Coding Practices
Jeff Channell - Secure PHP Coding Practices
vdrover
 
DataMapper
DataMapperDataMapper
DataMapper
Yehuda Katz
 
Symfony CMF - PHP Conference Brazil 2011
Symfony CMF - PHP Conference Brazil 2011Symfony CMF - PHP Conference Brazil 2011
Symfony CMF - PHP Conference Brazil 2011
Jacopo Romei
 
Core Php Component Presentation
Core Php Component PresentationCore Php Component Presentation
Core Php Component Presentation
John Coonen
 
Unittests für Dummies
Unittests für DummiesUnittests für Dummies
Unittests für Dummies
Lars Jankowfsky
 

Similar to Quebec pdo (20)

Working with databases in Perl
Working with databases in PerlWorking with databases in Perl
Working with databases in Perl
 
PHP CLI: A Cinderella Story
PHP CLI: A Cinderella StoryPHP CLI: A Cinderella Story
PHP CLI: A Cinderella Story
 
Introducing PHP Latest Updates
Introducing PHP Latest UpdatesIntroducing PHP Latest Updates
Introducing PHP Latest Updates
 
Php Data Objects
Php Data ObjectsPhp Data Objects
Php Data Objects
 
Zend framework 03 - singleton factory data mapper caching logging
Zend framework 03 - singleton factory data mapper caching loggingZend framework 03 - singleton factory data mapper caching logging
Zend framework 03 - singleton factory data mapper caching logging
 
Jdbc
JdbcJdbc
Jdbc
 
Fatc
FatcFatc
Fatc
 
Porting Applications From Oracle To PostgreSQL
Porting Applications From Oracle To PostgreSQLPorting Applications From Oracle To PostgreSQL
Porting Applications From Oracle To PostgreSQL
 
Debugging: Rules & Tools
Debugging: Rules & ToolsDebugging: Rules & Tools
Debugging: Rules & Tools
 
Doctrine and NoSQL
Doctrine and NoSQLDoctrine and NoSQL
Doctrine and NoSQL
 
Sa
SaSa
Sa
 
Perforce Object and Record Model
Perforce Object and Record Model  Perforce Object and Record Model
Perforce Object and Record Model
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applications
 
Xml Java
Xml JavaXml Java
Xml Java
 
Jeff Channell - Secure PHP Coding Practices
Jeff Channell - Secure PHP Coding PracticesJeff Channell - Secure PHP Coding Practices
Jeff Channell - Secure PHP Coding Practices
 
DataMapper
DataMapperDataMapper
DataMapper
 
Lecture17
Lecture17Lecture17
Lecture17
 
Symfony CMF - PHP Conference Brazil 2011
Symfony CMF - PHP Conference Brazil 2011Symfony CMF - PHP Conference Brazil 2011
Symfony CMF - PHP Conference Brazil 2011
 
Core Php Component Presentation
Core Php Component PresentationCore Php Component Presentation
Core Php Component Presentation
 
Unittests für Dummies
Unittests für DummiesUnittests für Dummies
Unittests für Dummies
 

Recently uploaded

Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 

Recently uploaded (20)

Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 

Quebec pdo

  • 1. PHP Data Objects Layer (PDO) Ilia Alshanetsky
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18. Array Fetching $res = $db->query(“SELECT * FROM foo”); while ($row = $res->fetch(PDO::FETCH_NUM)){ // $row == array with numeric keys } $res = $db->query(“SELECT * FROM foo”); while ($row = $res->fetch(PDO::FETCH_ASSOC)){ // $row == array with associated (string) keys } $res = $db->query(“SELECT * FROM foo”); while ($row = $res->fetch(PDO::FETCH_BOTH)){ // $row == array with associated & numeric keys }
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31. Prepared Statements in Action $stmt = $db->prepare( “ SELECT * FROM users WHERE id=?” ); $stmt->execute(array($_GET[‘id’])); $stmt->fetch(PDO::FETCH_ASSOC);
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.