Sayed Ahmed Computer Engineering, BUET, Bangladesh MSC, Computer Science, U of Manitoba, Canada

Slides:



Advertisements
Similar presentations
PHP II Interacting with Database Data. The whole idea of a database-driven website is to enable the content of the site to reside in a database, and to.
Advertisements

Widhy Hayuhardhika NP, S.Kom. Overview of database structure Connecting to MySQL database Selecting the database to use Using the require_once statement.
Data Access Worldwide May 16 – 18, 2007 Copyright 2007, Data Access Worldwide May 16 – 18, 2007 Copyright 2007, Data Access Worldwide Standardizing Application.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 13 Introduction to SQL Programming Techniques.
PHP and MySQL. Why Use a Database  Easy access to data  Simultaneous access by multiple users is handled properly  Security - easy to control access.
Manipulating MySQL Databases with PHP. PHP and mySQL2 Objectives Connect to MySQL from PHP Learn how to handle MySQL errors Execute SQL statements with.
Objectives Connect to MySQL from PHP
PHP and MySQL Web Development tMyn1 PHP and MySQL Web Development When you install PHP, you can select from a number of extensions. The MySQL support in.
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
An Introduction to PHP Data Objects A Better Way to Interact with Your Database by Rusty Keele.
OLE and ODBC: Taming the Technologies The Third Annual Perl Conference, 1999 Sunday, August 22, 1999Roth Consulting ODBC.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Introducing PHP Data Objects Wez Furlong
PHP Programming. Topics Background and History of PHP Installation Comments in PHP Variables Conditions Loops Functions File Handling Database Handling.
Advance Computer Programming Java Database Connectivity (JDBC) – In order to connect a Java application to a database, you need to use a JDBC driver. –
© Yanbu University College YANBU UNIVERSITY COLLEGE Management Science Department © Yanbu University College Module 6:WEB SERVER AND SERVER SIDE SCRPTING,
LIS651 lecture 7 PHP mySQL Thomas Krichel
MySQL in PHP – Page 1 of 17CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: MySQL in PHP Reading: Williams &
PDO, PHP Data Object Use a Database with PHP
Advanced Database Management System Lab no. 11. SQL Commands (for MySQL) –Update –Replace –Delete.
Chapter 7 PHP Interacts with Ms. Access (Open DataBase Connectivity (ODBC))
PHP Data Object (PDO) Khaled Al-Sham’aa. What is PDO? PDO is a PHP extension to formalise PHP's database connections by creating a uniform interface.
PHP Data Objects Layer (PDO) Ilia Alshanetsky. What is PDO Common interface to any number of database systems. Common interface to any number of database.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
FUNCTIONS AND STORED PROCEDURES & FUNCTIONS AND PROTECTING A DB AND PHP (Chapters 9, 15, 18)
_______________________________________________________________________________________________________________ PHP Bible, 2 nd Edition1  Wiley and the.
What is MySQLi? Since the mid-90s, Mysql extension has served as the major bridge between PHP and MySQL. Although it has performed its duty quite well,
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Chapter 6 PHP Interacts with Mysql Database. Introduction In PHP, there is no consolidated interface. Instead, a set of library functions are provided.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
PHP Part 2.
1. Connecting database from PHP 2. Sending query 3. Fetching data 4. Persistent connections 5. Best practices.
Lecture 10 – MYSQL and PHP (Part 2)
(Chapter 10 continued) Our examples feature MySQL as the database engine. It's open source and free. It's fully featured. And it's platform independent.
Accessing Your MySQL Database from the Web with PHP (Ch 11) 1.
PHP with MySQL 1.
Web-Based Database Programming with PHP. Dept. of Computing Science, University of Aberdeen2 In this lecture you will learn PHP Basics PHP functions –To.
Session 7: Getting PHP to Talk to MySQL. Objectives Connecting to the Database Building & Executing the SQL SELECT Query Fetching & Displaying the data.
CHAPTER 9 PHP AND MYSQL. A POSSIBLE SITE CONFIGURATION Application Folder index.php includes (folder)header.phpfooter.phpstyle.cssmodel (folder)mysqli_connect.php.
2010/11 : [1]PHP with MySQLBuilding Web Applications using MySQL and PHP (W1) PHP with MySQL.
Visual Programing SQL Overview Section 1.
1 CS 430 Database Theory Winter 2005 Lecture 14: Additional SQL Topics.
PHP Workshop ‹#› PHP Data Object (PDO). PHP Workshop ‹#› What is PDO? PDO is a PHP extension to formalise PHP's database connections by creating a uniform.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
PHP Workshop ‹#› أطلق إبداعك 2 أطلق إبداعك 2 مدرس معتمد من مركز زووم PHP Data Object (PDO)
PHP Programming. Topics Database Handling (MySQL, MSSQL, ODBC)
Database Access Using JDBC BCIS 3680 Enterprise Programming.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Chapter 8 Manipulating MySQL Databases with PHP PHP Programming with MySQL 2 nd Edition.
>> PHP: MySQL & CRUD. R ecall Database Tables Records is composed of Operations (CRUD) Create Retrieve Update Delete DBMS Access Control MySQL phpMyAdmin.
CSC 2720 Building Web Applications Accessing MySQL from PHP.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
Working With Database Library And Helpers. Connecting to your Database First you need to set parameters in you database.php file residing in config folder.
SQL and Java The vision for Java is to be the concrete and nails that people use to build this incredible network system that is happening all around us.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe.
JDBC.
1 PHP and MySQL Web Development When you install PHP, you can select from a number of extensions. The MySQL support in PHP consists of a number of functions.
Web Database Programming Using PHP
ASP.NET Programming with C# and SQL Server First Edition
JDBC Database Management Database connectivity
Web Database Programming Using PHP
Server-Side Application and Data Management IT IS 3105 (FALL 2009)
Chapter 19 PHP Part III Credits: Parts of the slides are based on slides created by textbook authors, P.J. Deitel and H. M. Deitel by Prentice Hall ©
Objectives Connect to MySQL from PHP Learn how to handle MySQL errors
ISC440: Web Programming 2 Server-side Scripting PHP 3
Web Programming– UFCFB Lecture
Presentation transcript:

Sayed Ahmed Computer Engineering, BUET, Bangladesh MSC, Computer Science, U of Manitoba, Canada

 Connection strategies  Configuration for connection in different frameworks  PHP and DB2, MSSQL Server  Common database oriented operations  Reference to DB oriented functions/classes

 mysql_connect  mysqli_connect  PDO  PDO_ODBC  Connection from Frameworks  Code Igniter – configure for db connection  CakePHP - configure for db connection  Zend - configure for db connection

 mysql_connect  Opens a connection to a MySQL Server  Deprecated as of PHP 5.5.0, and will be removed in the future.  Instead use MySQLi or PDO_MySQLMySQLiPDO_MySQL  mysql_connect examples

 application/config/database.php  $db['default']['hostname'] = "localhost"; $db['default']['username'] = "root"; $db['default']['password'] = ""; $db['default']['database'] = "database_name"; $db['default']['dbdriver'] = "mysql"; $db['default']['dbprefix'] = ""; $db['default']['pconnect'] = TRUE; $db['default']['db_debug'] = FALSE; $db['default']['cache_on'] = FALSE; $db['default']['cachedir'] = ""; $db['default']['char_set'] = "utf8"; $db['default']['dbcollat'] = "utf8_general_ci"; $db['default']['swap_pre'] = ""; $db['default']['autoinit'] = TRUE; $db['default']['stricton'] = FALSE;  Reference: 

 A copy of CakePHP’s database configuration file is found in  /app/Config/database.php.default  Make a copy of this file in the same directory, but name it  database.php  Change database.php as follows

 Zend_Config_Ini enables developers to store configuration data in a familiar INI format

 The name of the functions may closely resemble the functionality.  # mssql_ bind # mssql_ close # mssql_ connect # mssql_ data_ seek # mssql_ execute # mssql_ fetch_ array # mssql_ fetch_ assoc # mssql_ fetch_ batch # mssql_ fetch_ field # mssql_ fetch_ object # mssql_ fetch_ row # mssql_ field_ length # mssql_ field_ name # mssql_ field_ seek # mssql_ field_ type # mssql_ free_ result # mssql_ free_ statement

 # mssql_ get_ last_ message # mssql_ guid_ string # mssql_ init # mssql_ min_ error_ severity # mssql_ min_ message_ severity # mssql_ next_ result # mssql_ num_ fields # mssql_ num_ rows # mssql_ pconnect # mssql_ query # mssql_ result # mssql_ rows_ affected # mssql_ select_ db

 PHP has concepts like PDO and PDO_ODBC, and generic odbc features that will allow you to connect to and work with DB-2 databases. Generic odbc is the general/procedural way to connect to. PDO and PDO_ODBC are object oriented ways. PDO works with native IBM drivers. PDO_ODBC uses odbc connections to the DB2. For PHP you need to install drivers to support DB2. I worked with PDO_ODBC to connect to DB-2 databases in IBM iSeries servers. You need to install odbc db2 drivers for iseries servers. Then in /etc/odbcinst.ini file you need to mention driver specifications and in /etc/odbc.ini, you need to mention the odbc dsn name, database name, and some other parameters to connect to the database. Though, you may also supply some parameters in the PDO_ODBC connect method.iSeries database name

 mysqli::$affected_rows — Gets the number of affected rows in a previous MySQL operation mysqli::$affected_rows  mysqli::autocommit — Turns on or off auto-committing database modifications mysqli::autocommit  mysqli::begin_transaction — Starts a transaction mysqli::begin_transaction  mysqli::change_user — Changes the user of the specified database connection mysqli::change_user  mysqli::character_set_name — Returns the default character set for the database connection mysqli::character_set_name  mysqli::$client_info — Get MySQL client info mysqli::$client_info  mysqli::$client_version — Returns the MySQL client version as a stringmysqli::close — Closes a previously opened database connection mysqli::$client_versionmysqli::close

 mysqli::commit — Commits the current transaction mysqli::commit  mysqli::$connect_errno — Returns the error code from last connect call mysqli::$connect_errno  mysqli::$connect_error — Returns a string description of the last connect error mysqli::$connect_error  mysqli::__construct — Open a new connection to the MySQL server mysqli::__construct  mysqli::debug — Performs debugging operations mysqli::debug  mysqli::dump_debug_info — Dump debugging information into the log mysqli::dump_debug_info  mysqli::$errno — Returns the error code for the most recent function call mysqli::$errno

 mysqli::$error_list — Returns a list of errors from the last command executed mysqli::$error_list  mysqli::$error — Returns a string description of the last error mysqli::$error  mysqli::$field_count — Returns the number of columns for the most recent query mysqli::$field_count  mysqli::get_charset — Returns a character set objectmysqli::get_client_info — Get MySQL client info mysqli::get_charsetmysqli::get_client_info  mysqli_get_client_stats — Returns client per-process statistics mysqli_get_client_stats  mysqli_get_client_version — Returns the MySQL client version as an integer mysqli_get_client_version  mysqli::get_connection_stats — Returns statistics about the client connection mysqli::get_connection_stats  mysqli::$host_info — Returns a string representing the type of connection used mysqli::$host_info  mysqli::$protocol_version — Returns the version of the MySQL protocol used mysqli::$protocol_version  mysqli::$server_info — Returns the version of the MySQL server mysqli::$server_info  mysqli::$server_version — Returns the version of the MySQL server as an integer mysqli::$server_version  mysqli::get_warnings — Get result of SHOW WARNINGS mysqli::get_warnings

 mysqli::$info — Retrieves information about the most recently executed querymysqli::init — Initializes MySQLi and returns a resource for use with mysqli_real_connect()mysqli::$insert_id — Returns the auto generated id used in the last querymysqli::kill — Asks the server to kill a MySQL threadmysqli::more_results — Check if there are any more query results from a multi querymysqli::multi_query — Performs a query on the databasemysqli::next_result — Prepare next result from multi_querymysqli::options — Set optionsmysqli::ping — Pings a server connection, or tries to reconnect if the connection has gone downmysqli::poll — Poll connectionsmysqli::prepare — Prepare an SQL statement for executionmysqli::query — Performs a query on the databasemysqli::real_connect — Opens a connection to a mysql servermysqli::real_escape_string — Escapes special characters in a string for use in an SQL statement, taking into account the current charset of the connectionmysqli::real_query — Execute an SQL query mysqli::$infomysqli::initmysqli::$insert_idmysqli::killmysqli::more_resultsmysqli::multi_querymysqli::next_resultmysqli::optionsmysqli::pingmysqli::pollmysqli::preparemysqli::querymysqli::real_connectmysqli::real_escape_stringmysqli::real_query

 mysqli_stmt::$affected_rows — Returns the total number of rows changed, deleted, or inserted by the last executed statementmysqli_stmt::attr_get — Used to get the current value of a statement attributemysqli_stmt::attr_set — Used to modify the behavior of a prepared statementmysqli_stmt::bind_param — Binds variables to a prepared statement as parametersmysqli_stmt::bind_result — Binds variables to a prepared statement for result storagemysqli_stmt::close — Closes a prepared statementmysqli_stmt::data_seek — Seeks to an arbitrary row in statement result setmysqli_stmt::$errno — Returns the error code for the most recent statement callmysqli_stmt::$error_list — Returns a list of errors from the last statement executed mysqli_stmt::$affected_rowsmysqli_stmt::attr_getmysqli_stmt::attr_setmysqli_stmt::bind_parammysqli_stmt::bind_resultmysqli_stmt::closemysqli_stmt::data_seekmysqli_stmt::$errnomysqli_stmt::$error_list

 mysqli_result::$current_field — Get current field offset of a result pointermysqli_result::data_seek — Adjusts the result pointer to an arbitrary row in the resultmysqli_result::fetch_all — Fetches all result rows as an associative array, a numeric array, or bothmysqli_result::fetch_array — Fetch a result row as an associative, a numeric array, or bothmysqli_result::fetch_assoc — Fetch a result row as an associative arraymysqli_result::fetch_field_direct — Fetch meta-data for a single fieldmysqli_result::fetch_field — Returns the next field in the result setmysqli_result::fetch_fields — Returns an array of objects representing the fields in a result setmysqli_result::fetch_object — Returns the current row of a result set as an objectmysqli_result::fetch_row — Get a result row as an enumerated array mysqli_result::$current_fieldmysqli_result::data_seekmysqli_result::fetch_allmysqli_result::fetch_arraymysqli_result::fetch_assocmysqli_result::fetch_field_directmysqli_result::fetch_fieldmysqli_result::fetch_fieldsmysqli_result::fetch_objectmysqli_result::fetch_row

 mysqli_driver — The mysqli_driver classmysqli_driver::embedded_server_end — Stop embedded server mysqli_drivermysqli_driver::embedded_server_end  mysqli_driver::embedded_server_start — Initialize and start embedded server mysqli_driver::embedded_server_start  mysqli_driver::$report_mode — Enables or disables internal report functions mysqli_driver::$report_mode  mysqli_warning — The mysqli_warning classmysqli_warning::__construct — The __construct purpose mysqli_warningmysqli_warning::__construct  mysqli_warning::next — The next purpose mysqli_warning::next  mysqli_sql_exception — The mysqli_sql_exception class mysqli_sql_exception

 PDO::beginTransaction — Initiates a transactionPDO::commit — Commits a transactionPDO::__construct — Creates a PDO instance representing a connection to a databasePDO::errorCode — Fetch the SQLSTATE associated with the last operation on the database handlePDO::errorInfo — Fetch extended error information associated with the last operation on the database handlePDO::exec — Execute an SQL statement and return the number of affected rowsPDO::getAttribute — Retrieve a database connection attribute PDO::beginTransactionPDO::commitPDO::__constructPDO::errorCodePDO::errorInfoPDO::execPDO::getAttribute

 PDOStatement::bindColumn — Bind a column to a PHP variablePDOStatement::bindParam — Binds a parameter to the specified variable namePDOStatement::bindValue — Binds a value to a parameterPDOStatement::closeCursor — Closes the cursor, enabling the statement to be executed again.PDOStatement::columnCount — Returns the number of columns in the result setPDOStatement::debugDumpParams — Dump an SQL prepared commandPDOStatement::errorCode — Fetch the SQLSTATE associated with the last operation on the statement handlePDOStatement::errorInfo — Fetch extended error information associated with the last operation on the statement handle PDOStatement::bindColumnPDOStatement::bindParamPDOStatement::bindValuePDOStatement::closeCursorPDOStatement::columnCountPDOStatement::debugDumpParamsPDOStatement::errorCodePDOStatement::errorInfo

 PDOException — The PDOException class PDOException  PDO DriversCUBRID (PDO) — CUBRID Functions (PDO_CUBRID) PDO DriversCUBRID (PDO)  MS SQL Server (PDO) — Microsoft SQL Server and Sybase Functions (PDO_DBLIB) MS SQL Server (PDO)  Firebird/Interbase (PDO) — Firebird/Interbase Functions (PDO_FIREBIRD) Firebird/Interbase (PDO)  IBM (PDO) — IBM Functions (PDO_IBM) IBM (PDO)