Sie sind auf Seite 1von 5

4/13/2019 PHP: MySQL (Original) - Manual

Downloads
Documentation
Get Involved
Help

Search

Getting Started
Introduction
A simple tutorial
Language Reference
Basic syntax
Types
Variables
Constants
Expressions
Operators
Control Structures
Functions
Classes and Objects
Namespaces
Errors
Exceptions
Generators
References Explained
Predefined Variables
Predefined Exceptions
Predefined Interfaces and Classes
Context options and parameters
Supported Protocols and Wrappers

Security
Introduction
General considerations
Installed as CGI binary
Installed as an Apache module
Session Security
Filesystem Security
Database Security
Error Reporting
Using Register Globals
User Submitted Data
Magic Quotes
Hiding PHP
Keeping Current
Features
HTTP authentication with PHP
Cookies
Sessions
Dealing with XForms
https://www.php.net/manual/en/book.mysql.php 1/5
4/13/2019 PHP: MySQL (Original) - Manual

Handling file uploads


Using remote files
Connection handling
Persistent Database Connections
Safe Mode
Command line usage
Garbage Collection
DTrace Dynamic Tracing

Function Reference
Affecting PHP's Behaviour
Audio Formats Manipulation
Authentication Services
Command Line Specific Extensions
Compression and Archive Extensions
Credit Card Processing
Cryptography Extensions
Database Extensions
Date and Time Related Extensions
File System Related Extensions
Human Language and Character Encoding Support
Image Processing and Generation
Mail Related Extensions
Mathematical Extensions
Non-Text MIME Output
Process Control Extensions
Other Basic Extensions
Other Services
Search Engine Extensions
Server Specific Extensions
Session Extensions
Text Processing
Variable and Type Related Extensions
Web Services
Windows Only Extensions
XML Manipulation
GUI Extensions

Keyboard Shortcuts
?
This help
j
Next menu item
k
Previous menu item
gp
Previous man page
gn
Next man page
G
Scroll to bottom
gg
Scroll to top
gh
https://www.php.net/manual/en/book.mysql.php 2/5
4/13/2019 PHP: MySQL (Original) - Manual

Goto homepage
gs
Goto search
(current page)
/
Focus search box

Introduction »
« XSession::__construct

PHP Manual
Function Reference
Database Extensions
Vendor Specific Database Extensions
MySQL

Change language: English


Edit Report a Bug

Original MySQL API ¶


Introduction
Installing/Configuring
Requirements
Installation
Runtime Configuration
Resource Types
Changelog
Predefined Constants
Examples
MySQL extension overview example
MySQL Functions
mysql_affected_rows — Get number of affected rows in previous MySQL operation
mysql_client_encoding — Returns the name of the character set
mysql_close — Close MySQL connection
mysql_connect — Open a connection to a MySQL Server
mysql_create_db — Create a MySQL database
mysql_data_seek — Move internal result pointer
mysql_db_name — Retrieves database name from the call to mysql_list_dbs
mysql_db_query — Selects a database and executes a query on it
mysql_drop_db — Drop (delete) a MySQL database
mysql_errno — Returns the numerical value of the error message from previous MySQL operation
mysql_error — Returns the text of the error message from previous MySQL operation
mysql_escape_string — Escapes a string for use in a mysql_query
mysql_fetch_array — Fetch a result row as an associative array, a numeric array, or both
mysql_fetch_assoc — Fetch a result row as an associative array
mysql_fetch_field — Get column information from a result and return as an object
mysql_fetch_lengths — Get the length of each output in a result
mysql_fetch_object — Fetch a result row as an object
mysql_fetch_row — Get a result row as an enumerated array
mysql_field_flags — Get the flags associated with the specified field in a result
mysql_field_len — Returns the length of the specified field

https://www.php.net/manual/en/book.mysql.php 3/5
4/13/2019 PHP: MySQL (Original) - Manual

mysql_field_name — Get the name of the specified field in a result


mysql_field_seek — Set result pointer to a specified field offset
mysql_field_table — Get name of the table the specified field is in
mysql_field_type — Get the type of the specified field in a result
mysql_free_result — Free result memory
mysql_get_client_info — Get MySQL client info
mysql_get_host_info — Get MySQL host info
mysql_get_proto_info — Get MySQL protocol info
mysql_get_server_info — Get MySQL server info
mysql_info — Get information about the most recent query
mysql_insert_id — Get the ID generated in the last query
mysql_list_dbs — List databases available on a MySQL server
mysql_list_fields — List MySQL table fields
mysql_list_processes — List MySQL processes
mysql_list_tables — List tables in a MySQL database
mysql_num_fields — Get number of fields in result
mysql_num_rows — Get number of rows in result
mysql_pconnect — Open a persistent connection to a MySQL server
mysql_ping — Ping a server connection or reconnect if there is no connection
mysql_query — Send a MySQL query
mysql_real_escape_string — Escapes special characters in a string for use in an SQL statement
mysql_result — Get result data
mysql_select_db — Select a MySQL database
mysql_set_charset — Sets the client character set
mysql_stat — Get current system status
mysql_tablename — Get table name of field
mysql_thread_id — Return the current thread ID
mysql_unbuffered_query — Send an SQL query to MySQL without fetching and buffering the
result rows

add a note

User Contributed Notes 1 note


up
down
-107
sideshowAnthony at google dot com ¶
3 years ago
Here is a PDO helper class to get you started . . .

define('DB_MAIN', 'localhost|user1|pa55word|db1');

// Connect to database db1


$db = new my_db(DB_MAIN);

// Request "SELECT * FROM table1 WHERE a=16 AND b=22"


// Get an array of stdClass's
$rows = $db->fetchAll('SELECT * FROM table1 WHERE a=? AND b=?', 16, 22);

class my_db{

    private static $databases;


    private $connection;
https://www.php.net/manual/en/book.mysql.php 4/5
4/13/2019 PHP: MySQL (Original) - Manual

    public function __construct($connDetails){


        if(!is_object(self::$databases[$connDetails])){
            list($host, $user, $pass, $dbname) = explode('|', $connDetails);
            $dsn = "mysql:host=$host;dbname=$dbname";
            self::$databases[$connDetails] = new PDO($dsn, $user, $pass);
        }
        $this->connection = self::$databases[$connDetails];
    }
   
    public function fetchAll($sql){
        $args = func_get_args();
        array_shift($args);
        $statement = $this->connection->prepare($sql);       
        $statement->execute($args);
         return $statement->fetchAll(PDO::FETCH_OBJ);
    }
}

(Phillipus - I don't know what nationality you are, but the word "moron" is pretty offensive
in UK English. Thank you)
add a note

MySQL
Overview of the MySQL PHP drivers
MySQLi
Mysql_xdevapi
MySQL (Original)
Mysqlnd
mysqlnd_ms
mysqlnd_qc
mysqlnd_uh
mysqlnd_mux
mysqlnd_memcache

Copyright © 2001-2019 The PHP Group


My PHP.net
Contact
Other PHP.net sites
Privacy policy

https://www.php.net/manual/en/book.mysql.php 5/5

Das könnte Ihnen auch gefallen