Php sql 13
This presentation is the property of its rightful owner.
Sponsored Links
1 / 13

PHP +SQL 13 . PowerPoint PPT Presentation


  • 84 Views
  • Uploaded on
  • Presentation posted in: General

PHP +SQL 13. PHP + MySQL PHPMyAdmin Practice: Vote system. PHP +SQL 13. PHP + MySQL PHPMyAdmin Practice: Vote system. MVC = Model + View + Controller. The separation of the main layers, also one of the most important software development principle/pattern

Download Presentation

PHP +SQL 13 .

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

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


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Php sql 13

PHP+SQL13.

PHP + MySQL

PHPMyAdmin

Practice: Vote system

OE NIK, 2013


Php sql 131

PHP+SQL13.

PHP + MySQL

PHPMyAdmin

Practice: Vote system

OE NIK, 2013


Mvc model view controller

MVC = Model + View + Controller

  • The separation of the main layers, also one of the most important software development principle/pattern

  • PHP: very weak in the beginning, nowadays it is getting better and better (Symfony/CodeIgniter, Doctrine, APC/Memcached, Assetic)

Display layer(HTML + template)

Business logic layer(PHP)

Data (resource) layer(ORM)

OE NIK, 2013


Accessing databases in php

Accessing databases in PHP

  • The physical access of the database is done by database-server-dependent modules (MySQL, MSSQL, Oracle, Sybase, PostgreSQL, Firebird)

  • The physical communication of the SQL commands and the TCP communication are done using functions with different names and parameter syntax  alternative: DBX

  • ODBC: Access any standardized database server

  • PDO: PHP Data Objects (similar to Java DAO), MVC-like mapping, it connects the Model and the Control layers using SQL-independent methods  Doctrine is a lot better from the development side, but PDO is a lot faster ... We’ll skip this due to lack of OOP PHP. . .

OE NIK, 2013


Php and mysql

PHP and MySQL

  • libmysqld vs mysqlnd: physical connection

  • ext-mysql / ext-mysqli: Direct connection to a MySQL server, possibility to send out SQL commands directly

  • mysql_*  old, only procedural, but: a little faster, more conventional, but deprecated – not suggestedmysqli_*  new, possibility to work with OO, supports prepared statements and the execution of multiple queries and transactions(we will use this one, but WITHOUT OOP  )

  • When using them the procedural style, the mysql_* and the mysqli_* commands have different parameter order!

OE NIK, 2013


Mysql commands

MySQL commands

  • $conn=mysqli_connect(servername,username,password,dbname);

  • $res=mysqli_query($conn, $query);

  • $num=mysqli_insert_id($conn); // INSERT

  • $num=mysqli_affected_rows($conn); // UPD, DEL, INS

  • $num=mysqli_num_rows($res);

  • $row=mysqli_fetch_assoc($res);

    Check the databases slides onhttp://users.nik.uni-obuda.hu/szabozs/ !!!

OE NIK, 2013


Important things

Important things

  • $str=mysqli_real_escape_string($conn, $input); (prepared statement would be better. Please note that addslashes() is not safe, magic_quotes_gpc is ALWAYS OFF!)

  • $str=mysqli_error($conn);

  • $obj=mysqli_fetch_object($res);

  • mysql_set_charset($conn, "utf8"); (no mysql_query("set names 'utf8' ", $conn); )

OE NIK, 2013


Php sql 132

PHP+SQL13.

PHP + MySQL

PHPMyAdmin

Practice: Vote system

OE NIK, 2013


Phpmyadmin

PHPMyAdmin

OE NIK, 2013


Php sql 133

PHP+SQL13.

PHP + MySQL

PHPMyAdmin

Practice: Vote system

OE NIK, 2013


To do

To do

  • create database php;grant all privileges on php.* to [email protected] identified by 'phppw';

  • Create tables: questions (qu_id, qu_text) + choices (cho_id, cho_qu, cho_text, cho_num)

  • Insert some example questions and possible choices!

  • Actions: LISTQ, LISTC, VOTE, ADDQ, ADDC (+DELQ, DELC)

  • HTML files: Question-row, Choice-row, Add question form, Add choice form, Back link

OE NIK, 2013


Php sql 13

OE NIK, 2013


Php sql 13

OE NIK, 2013


  • Login