php PDO 链接 mysql 最简单 实例
define("DB_SERVER","127.0.0.1");
define("DB_PORT",3306);
define("DB_CATALOG","uab");
define("DB_USERID","root");
define("DB_PASSWORD","");
$dsn="mysql:host=".DB_SERVER.";port=".DB_PORT.";dbname=".DB_CATALOG;
self::$__PDO=new PDO($dsn, DB_USERID, DB_PASSWORD);
//support long connection
self::$__PDO=new PDO($dsn, DB_USERID, DB_PASSWORD, array(PDO::ATTR_PERSISTENT => true));
相关文档:
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 92160 bytes) in :\Inetpub\wwwroot04\test.php on line 8
Fatal error: Out of memory (allocated 259,260,416) (tried to allocate 16 bytes) in C:\Inetpub\wwwroot04\test.php on line 8
//ini_set('memory_limit', '-1');
$inde ......
安装以及配置
1. 安装Apache-2.2.4(Apache_Dir=D:\myspace\Apache-2.2.4)
2. 解压安装PHP-5.2.11(PHP_Dir=D:\myspace\PHP-5.2.11)
3. 找到PHP-5.2.11下的php.ini-dist,改名为php.ini
4. &nb ......
<?php
//作者:梁文平 http://www.tyasp.net
session_start();
if($_SESSION["username"]!="admin")
{
echo("<mce:script type="text/javascript"><!--
alert("操作超时!请重新登陆...");window.location.href="../index.php";
// --></mce:script>");
//header("refresh:0;url=../"); ......
PHP中有下列称之为魔术方法(magic method)的函数:__construct, __destruct ,
__call, __callStatic,__get, __set, __isset, __unset , __sleep, __wakeup,
__toString, __set_state, __clone and __autoload,本文使用__call为实现一个身份验证的简单实例,代码如下: 代码<?php
interfa ......
/*查询数据库*/
show databases;
/*创建数据库*/
create database dengheping;
/*使用数据库*/
use dengheping;
/*创建表*/
create table user(id int primary key auto_increment,name char(255));
/*查询表*/
show tables;
/*显示表结构*/
desc user;
/*插入字段*/
alter table user add password varchar(6 ......