mysql一些方法
dirname(__FILE__); //得到的是文件所在层目录名 注意:在 Windows 中,正斜线(/)和反斜线(/)都可以用作目录分隔符。在其它环境下是斜线(/)。 define('TIME', time());//定义常量 echo gmdate('D, d M Y H:i:s', TIME); //输出常量 require dirname(__F
dirname(__FILE__); //得到的是文件所在层目录名
注意:在 Windows 中,正斜线(/)和反斜线(/)都可以用作目录分隔符。在其它环境下是斜线(/)。
define('TIME', time());//定义常量
echo gmdate('D, d M Y H:i:s', TIME); //输出常量
require dirname(__FILE__).'/chen_class/mysqlconn.php'; //引用外部文件
@是在程序出现错误时,屏蔽错误信息,不把错误信息显示在页面上.
//输出本页编码为utf-8
header("content-type:text/html; charset=utf-8");
//三种取值方法
$_REQUEST[]
$_POST[]
$_GET[]
//定义类
class mysql_access
{
function conn()
{
$dbh = mysql_connect('110.110.110.36','root','111111');
mysql_select_db('1234',$dbh);
$query ="select * from phpcms_ask_actor;";
//mysql_query("SET CHARACTER_SET_RESULTS=UTF8'");
mysql_query("set names utf8;");
$res = mysql_query($query, $dbh);
mysql_query("INSERT INTO phpcms_ask_actor(typeid,grade,actor,MIN,MAX) VALUES(5,'陈建平','是一个大好人!',4,5);");
}
}
?>
//php连接mssql数据库
$dbhost="110.110.110.39";
$dbuser="sa";
$dbpwd="111111";
$my_conn=@mssql_connect($dbhost,$dbuser,$dbpwd) or die("数据库连接错误!");
mssql_select_db('pubs',$my_conn);
$sql=mssql_query(iconv('UTF-8',"gbk","insert into jobs(job_desc,min_lvl,max_lvl) values('陈建',34,45)")); //解决汉字输入问题
$result =@mssql_query($sql,$my_conn);
mssql_close($my_conn);
extract($_POST);
//相当于$username = $_POST['username'];
//$password = $_POST['password'];
//页面调用类
$mysql_access = new mysql_access;
$mysql_access->conn();
//字符串相加
$output = " "; //必须要空一格否则与其它字符串相加也为空。
$output=$output."daddd";
//剪除指定字符
trim($strings,",");
trim($strings) ; //参数2为空时默认去掉头尾空格,制表,换行,回车,空值。
//截取字符串
substr($str4,2,45); //第2个参数代表起始位置的索引值(从0开始,取值包括),第三个参数代表要取字符个数
//替换字符串
str_replace("aa","bb","chen aa aa",$i); //第一个参数old字符串,第二个参数新字符串,第三参数要编辑的字符串[,第四个参数指替换字符串的个数]
//数组
自动分配 ID 键:
$names = array("Peter","Quagmire","Joe");
//取值
$names[0]
//关联数组
$ages = array("Peter"=>32, "Quagmire"=>30, "Joe"=>34);
//取值
$ages['Peter']
array_keys($memberinfo);//取数组键值
//自动取出数组,并用第一个参数分隔开
implode(' ', $memberinfo)
//多维数组:
$families = array
(
"Griffin"=>array("Peter","Lois","Megan"),
"Quagmire"=>array("Glenn"),
"Brown"=>array("Cleveland","Loretta","Junior")
);
//取值
$families['Griffin'][2]

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

In MySQL, the function of foreign keys is to establish the relationship between tables and ensure the consistency and integrity of the data. Foreign keys maintain the effectiveness of data through reference integrity checks and cascading operations. Pay attention to performance optimization and avoid common errors when using them.

IIS and PHP are compatible and are implemented through FastCGI. 1.IIS forwards the .php file request to the FastCGI module through the configuration file. 2. The FastCGI module starts the PHP process to process requests to improve performance and stability. 3. In actual applications, you need to pay attention to configuration details, error debugging and performance optimization.

The main difference between MySQL and MariaDB is performance, functionality and license: 1. MySQL is developed by Oracle, and MariaDB is its fork. 2. MariaDB may perform better in high load environments. 3.MariaDB provides more storage engines and functions. 4.MySQL adopts a dual license, and MariaDB is completely open source. The existing infrastructure, performance requirements, functional requirements and license costs should be taken into account when choosing.

SQL is a standard language for managing relational databases, while MySQL is a database management system that uses SQL. SQL defines ways to interact with a database, including CRUD operations, while MySQL implements the SQL standard and provides additional features such as stored procedures and triggers.

Multiple calls to session_start() will result in warning messages and possible data overwrites. 1) PHP will issue a warning, prompting that the session has been started. 2) It may cause unexpected overwriting of session data. 3) Use session_status() to check the session status to avoid repeated calls.

AI can help optimize the use of Composer. Specific methods include: 1. Dependency management optimization: AI analyzes dependencies, recommends the best version combination, and reduces conflicts. 2. Automated code generation: AI generates composer.json files that conform to best practices. 3. Improve code quality: AI detects potential problems, provides optimization suggestions, and improves code quality. These methods are implemented through machine learning and natural language processing technologies to help developers improve efficiency and code quality.

MySQL and phpMyAdmin can be effectively managed through the following steps: 1. Create and delete database: Just click in phpMyAdmin to complete. 2. Manage tables: You can create tables, modify structures, and add indexes. 3. Data operation: Supports inserting, updating, deleting data and executing SQL queries. 4. Import and export data: Supports SQL, CSV, XML and other formats. 5. Optimization and monitoring: Use the OPTIMIZETABLE command to optimize tables and use query analyzers and monitoring tools to solve performance problems.
