Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
14 views
RDBMS
Php notes
Uploaded by
gurawtarsingh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save RDBMS For Later
Download
Save
Save RDBMS For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
14 views
RDBMS
Php notes
Uploaded by
gurawtarsingh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save RDBMS For Later
Carousel Previous
Carousel Next
Save
Save RDBMS For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 24
Search
Fullscreen
Ea Oslo Bare connec Harty woth ys | RDBMS > cet for relatinal DEMS. Sou, Ovacte , Mya , ore Sore om RSBMA. + Dats ib peprucnted tr dew 4 + tuples (due) iw RDRMA, » Cortes primoy ens, ‘ Bupplir Jobe Posts Fobte A wD Ib_feperties - Setegety Duredity roti, 1 ety PHR Cenneete tM) > MysGLr extention, (t= improved) | ~» Pdo ( PHP dodo rae O will Work on gee will oa work i foeut ds aprose | aie muyage. ax ofyect omer} : 00 + ares APL,zend Ter» conany yy Q Aa a wy @ ¢ “Mus MAGENTO PRUPAL Cah WORD PRESS zencart | Integrating PHP and Database [SB DATABASE Data is a very important resource in the operation and management of an organization. sit is very essential to organize the data in a meaningful manner, because an unorganized im has no meaning. With the increased demand of the data in the various organizations suchas banks, universities, railways, airlines, companies etc,, it becomes a necessity to store {sain an organized manner so that it can be used again and again. So, we need a database ‘osore the data in an organized form. Database can be defined as “A well-organized collection of data that are related in a seaningful way, which can be accessed by different users but stored only once” te sent my comes [yA Usge2 organizes Related + to.eacn othor User Fig. 8.1 (Database)«Me MySQL 7 rat Functions used in PHP - a of MySQL Database and Tables a Ee Fetch and delete records through MysaL 5 {a INTRODUCTION eve jatabase is a collection of information t sj managed and updated, Its used by xe and retrieving information. Datab; managing @ grams. by progra hat is organized so that it can any Organization as a method of storing, ‘ase organizes data for easy access and use be easily To interact with database in PHP, it is better ‘o intera option to use SQL. The most database construct is the table. For example, if you have a database named ee and you wanted to recover the records from that table, the output might be as shown below: 1001 ABC MCA dent 1002 XYZ MCAThis query gives you a record Student table, Here = repre In PHP, that record set following st set containing all m, sents all records in the student tis retumed ‘atement shows how to Squery = “select * trom stident Srersuit = mysql_query($query) or die(“Query failed Sresult holds an array with the records for the student ta fields of each record by name latching. recordg table. fom the The as an array and your can loop over y write SQL queries i th in PHP code, atray, the 's a Relational DataBase M. Janagement S; rv 'ystem (RDBMS) M4 et qrchitecture in which the server tune ont clients connect to the server over @ Retworh 4 Linux or Windows operating system Ty; Sh Windows, Windows Server, Red He: Fedora Linux, and As with any other client/serv. meaning several users can * The server (MySQL server and accesses datal to the clients, SQL opera the machine Contains k. The server o, systems is usually ) listens for client rex quests coming in oy base contents according to those requests and SQL 'ge) language. The client program may creeatrari® Setver programmatically (meanings Program call the server during tela n).oF manually. For example, when yourar i telnet ses ‘ion to. a MySQ\ suing commands over ¢ by typing commands at We requests to the server Your command prompt manually, 8.3 FEATURES OF MYSQL Following are some most important features of MySQL: * RDBMS: MySQL is relational database * Speed. MySQL is fast. Its devel database system you can get. * Ease of use. MySQL is easy to use. It is simple database system and is much le larger systems. You have management system. lopers contend that MySQL is about the fastest a high-performance but relatively 's8 complex to set up and administer than to get only the basic knowledge of SQL8.2.3 MYSQL is al database management system (DBM urce relation. company MySQL AB, now owned by Oracle Corporation, MySQL is an open s0' including Microsoft Windows, UNry, developed by a Swedish MySQL supports many different platforms Linux, Symbian and Mac OS X. MySQL is completely free and open- and installation. source. It is available for free downloa MySQL was initially released in 1995. Supported programming languages in MySQL are: C, C#, C++, Java, Per PH Python, and Ruby. MySQL is suitable for personal websites and web applications for small businesses. MySQL uses three parameters to authenticate a user namely user name, passiir! and location.¢ Fd PHP and Database a MYSQL WITH PHp pHP can work with virtually all database packages, goes Microsoft SQL Server and MySQL. MySQL is the m a with PHP due to following reasons: «MySQL is a database system used on the web. MySQL is a database system that runs ona server. + MySQL is ideal for both small and large applications. + MySQL is free to download and use. including MS-Access, Oracle, ‘ost popular database package + MySQL compiles on a number of platforms. « MySQL is very fast, reliable, and easy to use. « MySQL supports standard SQL. {Note: Before to build a connection of PHP document with MySQL Server, make sure that {myst server must be properly configured on your system. You can download MySQL | server from the following URL: http://cdn.mysql.com/Downloads/MySQLInstaller/mysql-installer-community- | 5.6.12.1.msi[ Before to build a connection of a PHP document with MYSQL database, you must understand about how to create and use a database in MYSQL.£ WEB APPLICATION DEVELOPMENT USING pip 8.4 MYSQL FUNCTIONS USED IN PHP Following tables show MySQL s the MySQL functions used in PHP to interact with oY mysql_affected_rows() mys. changeover | mysal_client_encoding() mysql_close() mysql_connect) mysql_create_db() mysql_data_seek() mysql_db_name() mysql_db_query() mysql_drop_db() mysql_errno() mysql_error() mysal_escape_string() mysql_fetch_array() mysql_fetch_assoc() mysql_fetch_field() mysql_fetch_lengths() g|_fetch_object() fetch_row() Id_flags() tt returns the number of affected rows in the previous MySQL operation Change the logged-in user Returns the name of the character set for the current connection Closes a MySQL connection Opens @ MySQL connection Create a MySQL database Moves the record pointer. Used to seek data in the database. It returns a database name. Sends a MySQL query. Deprecated. Deletes a MySQL database. Use mysql_query() instead Returns the error number of the last MySQL operation Returns the error description of the last MySQL operation Escapes a string for use in a mysql_query. Returns a row from a recordset as an associative array and/or a numeric array Returns a row from a recordset as an associative array Returns column info from a recordset as an object Returns the length of the contents of each field in a result row Retums a row from a recordset as an object Returns a row from a recordset as @ numeric array Returns the flags associated with a field in a recordset Returns the maximum length of a field in a recordsetLee) Returns the name of a field in a recordset Moves the result pointer to a specified field Returns the name of the table the specified feld is in Returns the type of a field in a recordset Free result memory Returns MySQL client info Returns MySQL host info Returns MySQL protocol info Returns MySQL server info Returns information about the last query Returns the AUTO_INCREMENT ID generated from the previous INSERT operation Lists available databases on a MySQL server Lists MySQL table fields. Lists MySQL processes Lists tables in 2 MySQL database. uit 50) lst fet0s0) lst processes() ce ist tables) 4 rum feld50) Returns the number of fields in a recordset caro vj. surn_F0Ns() Returns the number of rows in a recordset Opens a persistent MySQL connection Pings a server connection or reconnects if there is no connection Executes 2 query on a MySQL database Escapes a string for use in SQL statements din a recordset sysi_pcomnect() cin) sey) rysq_eal_escape_string() Returns the value of a fie sy resut() sysdselect_db() Sets the active MySQL database se stat() Returns the current system status of the MySQL server isa tablename() Returns the table name of field Ise. thread_id() Returns the current thread ID Executes a query on a MySQL database (without Mrel_unbuffered_query() fetching / buffering the re sult) sweated 3s of P released on The MySQL extension is officially deprecated of PP 5.5 ae Jone Zong), tt nes been removed entirely. as of PHE 7.0 (orm iy December 2015), Instead, the MySQU or PDO_MySQL be used, i8.5 PHP 5 MYSQLI FUNCTIONS Caan a Peery mysqli_affected_rows() Returns the number of affected rows iq th J % previous MySQL operation 3 ‘mysqli_autocommit() Turns on or off auto-committing databace modifications mysqli_change_user() Changes the user of the specified database connection mysqli_character_set_name() Returns the default character set for the database connection mysali_close() Closes @ previously opened database comet mysali_commit() Commits the current transaction mysqli_connect_ermo() Returns the error code from the last connection error mysqli_connect_error() Returns the error description from the last connection error —‘ysqli_connect() Opens @ new connection to the MySQL sener mysqli_data_seek() Adjusts the result pointer to an arbitrary row in the result-set mysqli_debug() Performs debugging operations mysqli_dump_debug_info() mysqli_errno() Dumps debugging info into the log Returns the last error code for the most recent function call mysqli_error_list() Returns a list of errors for the most recent function call mysqli_error() Returns the last error description for the most recent function call mysqli_fetch_all() Fetches all result rows as an associative aay, @ numeric array, or both ysali_fetch_array() Fetches a result row as an associative, @ numeric array, or both Ji_fetch_assoc() Fetches a result row as an associative aay fetch field_direct() Returns meta-data for a single field in the resut set, as an objectayant feld_seek() spt eld tell) sea tree_result() iysai_get_charset() ont Ipysai_ get_client_stats() = jient_version() [sail get connection stats() ji_get_ost_info() get client_info() all_get_proto_info() pali_get_server_info() iali_get_server_version() info) er Returns the next field eet in the resutt set, as an Returns an arr ‘ay of objects th faa Ge at represent the Returns the len gths of the columns of the current row in the result set Ret feturns the current row of a result set, as an object Fetches one row from a result-set and returns it as an enumerated array Returns the number of columns for the most recent query Sets the field cursor to the given field offset Returns the position of the field cursor Frees the memory associated with @ result Returns a character set object Returns the MySQL client library ve statistics about client per-pro sion cess Returns Returns the MySQL cient library version 25 8” integer eturns statistics about the client connection returns the MySQL server hostname and the connection tyPe returns the MySQL protocol version returns the MySQL server version turns the MySQL server version ‘an integer returns information about tne most recently executed query iraizes MYSQL and returns & resource for use wath, mysai_reat.connect) peturns une aurorgenerated I used in the last query sks the server to Kill 2 mysql threadDae I - a | Checks f there are more results fom 2 muti quan Performs one or more queries on the databay mysqli_mutti_query() Prepares the next result set from mysqli_multi_query() mysqli_next_result() mber of fields in a mysali_num_fields() Returns the nu Fesult set Fi aie BNGO Returns the number of rows in a result set Sets extra connect options and affect behav mysqli_options() : for a connection mysali_ping() Pings a server connection, oF tries to recone if the connection has gone down mysali_prepare() Prepares an SQL statement for execution mysqli_query() Performs a query against the database mysali_real_connect() Opens a new connection to the MySQL server mysqli_real_escape_string() Escapes special characters in a string for use in an SQL statement mysqli_real_query() Executes an SQL query mysqli_reap_async_query() Returns the result from async query mysqli_refresh() Refreshes tables or caches, or resets the replication server information mysali_roliback() Rolls back the current transaction for the database mysali_select_db() Changes the default database for the connecton mysqli_set_charset() Sets the default client character set mysqli_set_local_ file_default() Unsets user defined handler for load local infle command 8.6 CONNECTING TO THE DATABASE SERVER PHP connects the database using. connection objects. mysql_connect function is used connect a database with PHP. The syntax of mysql_connect function is: ‘mysql_conneet({server [, username [, password [, new/_link{, client tlagslll) The various parameters of mysql_connect function are: server : It is the name of the MySQL server, which can be URLs, port numbers and so on.ing et and Database ti ‘ ont, This y 4 list of available databases, use the SHOW DATABASES statement. fo * ‘iin the names of databases to which you have no access: ont“ fe ot show Per peas Ue Luis TUL information_schema oo era Petron nd es Poi Pera un a CONNECTING TO DATABASE (MYSQL) gs data from MySQL | open a Connection to the MySQL Server: Before to acce arver. In PHP, this is database, you have to open or build a connection with MySQL se done with the mysqli_connect0 function. ax of mysqli_connect() function is: synta snysqli_conneet(hostusername,passwordabmame) tee, the parameter host represents the host name where database resides, username «the password required to Tog in and password represent the MySQL username, d when performing quer default database to be use’ epresents vane represents the sample: title» Database connection with MySQL-
“ After the execution of above code, the out} i_connect_error(); put would be look like: J Database connection with My... €)@ tocathost/dbphp | | Q Search Database Connection successfully build + Close a Connection: The connection will be closed automatically when the sep the connection before, use the mysqli_close() function: se connection with MySQLting PHP and Database ee ne Nats “.mysqli_connect_error(); ! else | echo "Database Connection successfully build"; J) Close connection mysqli_close($con); echo "
Database Connection successfully closed’; D>
After the execution of above code, the output would be look like: J Close Database connection x GE €).© locathostidbe pp || & Search Database Connection successfully build Database Connection successfully closedJUINUDE Le ee sis eSee SEH L_UN LER ACTIVE, e nine me ny sqi_connect function returns a connection object if successful «se. Following example shows how to connect a database using \ “iL oe s mysql_connect | tion in PHP ehtml> chead>
CONNECT DATABASE
ch1>CONNECTING DATABASE fe
ceeasnuuay cavonn fa CREATING A DATABASE AND DATABASE TABLE «Create a Database: The CREATE DATABASE statement is used to create a database table in MySQL. You must add the CREATE DATABASE statement to the mysqli_query() function to execute the command. Eample:
Create a Databases/title>
Database BCA created successfully”; 187 CREATE A MYSQLI DATABASE IN PHP the CREATE DATABASE] statement is used to create a database in MySQL. After ting a connection with MySQL, you can create database. = - Following example shows how to create database using PHP: cctitle> CREATE DATABASE._ ea CCCs: NG D
CREATING DATABASE ee xo $CONNECTION = mysqli_ connect("localhost","root’, password"); if(($CONNECTION) ms ” - a { np i die (“Couldn't connect to server”); } echo “Connected Successfully
"; 1! Create database ~ §sqI"Gery = “CREATE DATABASE m ob eat Seep RSONNECTION Saco e ¥ mysqli_close($CONNECTION); > The output of the above code is: € > SC @ OD leaahostreate database php CREATING DATABASE Connected SuccessfullyTARLE aes Towle command ‘hunad t uate O ‘ Ty MYSQL + You can Uyenne Zamt Broctet ‘PHP +e wate a table undin asisear® BCA. Roppusag , > You muss add Yue Coote Tacs axokawont | my bi gun ty funda % enact See Cornnnond + : | Noung PUP toda. VSN cust, talela nomad Crud nde BCA dotaloare! iw? Maad' Wc DATABACE 2] HUL> L[hsod> chy, ig Cone hon copy ie cased Ceca hos’? “pect! Spaunse ch”). 2, EF rk Nae Chosr( 20), ant)":pei corey ae Vie cQose cameo : meng - Caronecton C& ton)» C13 as, aN ‘Guru Nanak Dev Engineering College, Ludhiana, Tanartmant af Commuter Applications: oa |After the execution of above code, the output would be look like: Create a Table «Ge € |(Q Search €) © locathost/ct.php Database Connection successfully build Table STUDENT created successfully“intearating PAP amie ties =n an acenng pene eee Qrom PrP Ta bart a Mysa- AOPped Up in PHP Punction rng bt guts ELECT ja NoEeT, DELETE, LEDATE- @ MySQL Command ts CREATE ox DROP a abou Aablecan also 2 wed with Vhis bP er myqb-q ussy 0) tank a Paleord ytte tebole oltne (soley ake and oa table. ERT pute Gotmank fx Wad add new albare corble- B -, cxecectas the INSERT Grokwmend Spy ig wey () funtion ¢ wrod ts Zend a mone ON + aed oe“2 . on S Gm = = mysqhi Coomect C Pocal. hast “root a “ech ), ck Commectiom C}&em) re (Couldn't Commect te Aero wo’), ectad Saccere fully tonrciand' Arcosd ints salle q CF tan STrgeseh twits Skuskerck FSNME, Nae Age) Vabuss( SPAS) omar? pole i Ant ccudont (Ros Rant, Laxwoums | ws (PREM! SKomnk! yas e2 a
You might also like
Chap 6-Php Mysql
PDF
No ratings yet
Chap 6-Php Mysql
25 pages
web programming lecture 7
PDF
No ratings yet
web programming lecture 7
20 pages
web programming lecture 6
PDF
No ratings yet
web programming lecture 6
13 pages
TY CO PhP Unit 05
PDF
No ratings yet
TY CO PhP Unit 05
12 pages
Mysql PHP Tutorial: Ferry Boender
PDF
No ratings yet
Mysql PHP Tutorial: Ferry Boender
17 pages
Unit 6
PDF
No ratings yet
Unit 6
78 pages
Psa6-Rice in A Box
PDF
No ratings yet
Psa6-Rice in A Box
51 pages
PHP and Mysql - Unit-V
PDF
No ratings yet
PHP and Mysql - Unit-V
38 pages
Chapter 5 of PHP (WBP)
PDF
No ratings yet
Chapter 5 of PHP (WBP)
25 pages
Advanced IP-Chapter-4 - Lect-8, 9
PDF
No ratings yet
Advanced IP-Chapter-4 - Lect-8, 9
44 pages
CH 3
PDF
No ratings yet
CH 3
22 pages
Lecture Notes Week 06
PDF
No ratings yet
Lecture Notes Week 06
27 pages
PHP JT unit4
PDF
No ratings yet
PHP JT unit4
26 pages
Chap 7 PHP MySQL Database
PDF
No ratings yet
Chap 7 PHP MySQL Database
33 pages
PHP Mysql
PDF
No ratings yet
PHP Mysql
5 pages
Unit - 5
PDF
No ratings yet
Unit - 5
16 pages
PHP 5 and Mysql Database
PDF
No ratings yet
PHP 5 and Mysql Database
19 pages
7 PHP MYSQL Database_230417_115430
PDF
No ratings yet
7 PHP MYSQL Database_230417_115430
25 pages
16 Lectures On MYSQL DATABASE Statements
PDF
No ratings yet
16 Lectures On MYSQL DATABASE Statements
16 pages
PHP Database
PDF
No ratings yet
PHP Database
20 pages
Basic PHP Database MYSQL For Beginners
PDF
100% (4)
Basic PHP Database MYSQL For Beginners
21 pages
Unit 5 WBP PHP 22619 02
PDF
No ratings yet
Unit 5 WBP PHP 22619 02
47 pages
Mysql
PDF
No ratings yet
Mysql
24 pages
Rdms nots bca php
PDF
No ratings yet
Rdms nots bca php
3 pages
SQL To PHP
PDF
No ratings yet
SQL To PHP
15 pages
Original Mysql Api: Search
PDF
No ratings yet
Original Mysql Api: Search
2 pages
Introduction To Relational Database (RDBMS) - MySQL
PDF
No ratings yet
Introduction To Relational Database (RDBMS) - MySQL
22 pages
Chapter 3 & 4
PDF
No ratings yet
Chapter 3 & 4
27 pages
MySQL Basic To Advance Sanket Mishrikotkar 1658256716
PDF
No ratings yet
MySQL Basic To Advance Sanket Mishrikotkar 1658256716
64 pages
IP-II-Chapter 7.ppt
PDF
No ratings yet
IP-II-Chapter 7.ppt
73 pages
Chapter 05
PDF
100% (1)
Chapter 05
20 pages
Introduction To Mysql & PHP: Presented By, M.Pravin Raj
PDF
No ratings yet
Introduction To Mysql & PHP: Presented By, M.Pravin Raj
14 pages
PHP Database
PDF
No ratings yet
PHP Database
13 pages
IP 3 Chapter Edit
PDF
No ratings yet
IP 3 Chapter Edit
37 pages
DWPD GTU Study Material E-Notes Unit-5 03082019063134AM PDF
PDF
No ratings yet
DWPD GTU Study Material E-Notes Unit-5 03082019063134AM PDF
16 pages
PHP & MySQL
PDF
No ratings yet
PHP & MySQL
42 pages
DWPD GTU Study Material E-Notes Unit-5 22092020071825AM
PDF
No ratings yet
DWPD GTU Study Material E-Notes Unit-5 22092020071825AM
16 pages
PHP Programming - Day 6 - 4
PDF
No ratings yet
PHP Programming - Day 6 - 4
14 pages
Mysql - Introduction: What Is A Database?
PDF
No ratings yet
Mysql - Introduction: What Is A Database?
12 pages
Chapter 4-Connecting To Databases
PDF
No ratings yet
Chapter 4-Connecting To Databases
20 pages
PHP Tutorial - W3schools2 PDF
PDF
No ratings yet
PHP Tutorial - W3schools2 PDF
88 pages
Unit 4 WP Notes
PDF
No ratings yet
Unit 4 WP Notes
14 pages
Unit 5 PHP
PDF
No ratings yet
Unit 5 PHP
12 pages
PHP With Mysql
PDF
No ratings yet
PHP With Mysql
8 pages
L 22 PHP and MySQL Connectivity
PDF
No ratings yet
L 22 PHP and MySQL Connectivity
40 pages
Lec 06 MySQL in PHP PDF
PDF
No ratings yet
Lec 06 MySQL in PHP PDF
24 pages
3 Chapter Edit
PDF
No ratings yet
3 Chapter Edit
46 pages
Chapter 5
PDF
No ratings yet
Chapter 5
14 pages
Last Nam e First Nam e Addre Ss City
PDF
100% (1)
Last Nam e First Nam e Addre Ss City
13 pages
Chapter 3 Database Manipulation
PDF
No ratings yet
Chapter 3 Database Manipulation
41 pages
Unit 4 - PHP 0 Mysql Notes
PDF
No ratings yet
Unit 4 - PHP 0 Mysql Notes
62 pages
Interacting With Database Using MySQL
PDF
No ratings yet
Interacting With Database Using MySQL
4 pages
Web Chapter 6
PDF
No ratings yet
Web Chapter 6
54 pages
Cs 3548 7 Mysql
PDF
No ratings yet
Cs 3548 7 Mysql
23 pages
Unit 5: Advanced PHP & Mysql: Web Programming
PDF
No ratings yet
Unit 5: Advanced PHP & Mysql: Web Programming
22 pages
Presentation Mysql Training 1499248676 292960
PDF
No ratings yet
Presentation Mysql Training 1499248676 292960
77 pages
WP Chapter Six
PDF
No ratings yet
WP Chapter Six
55 pages
Unit-V Database Operations
PDF
No ratings yet
Unit-V Database Operations
19 pages
Unit4 Phpdatabase
PDF
No ratings yet
Unit4 Phpdatabase
3 pages