mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
* Add OOP example for extending mysqli.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@277120 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
c68df084c7
commit
b612456307
1 changed files with 27 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.12 $ -->
|
||||
<!-- $Revision: 1.13 $ -->
|
||||
<refentry xml:id="mysqli.connect" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>mysqli::__construct</refname>
|
||||
|
@ -176,6 +176,32 @@ $mysqli->close();
|
|||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<example>
|
||||
<title>Object oriented style when extending mysqli class</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
class foo_mysqli extends mysqli {
|
||||
public function __construct($host, $user, $pass, $db) {
|
||||
parent::__construct($host, $user, $pass, $db);
|
||||
|
||||
if (mysqli_connect_error()) {
|
||||
die('Connect Error (' . mysqli_connect_errno() . ') '
|
||||
. mysqli_connect_error());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$db = new foo_mysqli('localhost', 'my_user', 'my_password', 'my_db');
|
||||
|
||||
echo 'Success... ' . $db->host_info . "\n";
|
||||
|
||||
$db->close();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<example>
|
||||
<title>Procedural style</title>
|
||||
<programlisting role="php">
|
||||
|
|
Loading…
Reference in a new issue