Home > PHP Framework > ThinkPHP > body text

Is thinkphp object-oriented?

WBOY
Release: 2022-06-21 11:02:47
Original
2428 people have browsed it

thinkphp is object-oriented; thinkphp is a free, open source, fast, simple, object-oriented lightweight PHP development framework, which was born to simplify enterprise-level application development and agile WEB application development. Open source lightweight PHP framework.

Is thinkphp object-oriented?

The operating environment of this article: Windows 10 system, ThinkPHP version 6, Dell G3 computer.

Is thinkphp object-oriented?

ThinkPHP is a free, open source, fast and simple object-oriented lightweight PHP development framework for agile WEB application development and simplified enterprise applications. Developed and born.

ThinkPHP can support server environments such as windows/Unix/Linux. The official version requires PHP5.0 or above. It supports MySql, PgSQL, Sqlite databases and PDO extensions. The ThinkPHP framework itself has no special module requirements. The specific application system operating environment requirements depend on the modules involved in development.

Founded in early 2006, it was born for the development and simplification of agile WEB application development and enterprise applications. From the beginning, ThinkPHP has always followed simple and practical design principles, focusing on ease of use, while maintaining superior performance and simplicity. Code, with many original features, the team optimized ease of use, scalability and performance to improve the stability of the most advanced and powerful WEB application development framework.

Thinkphp database object-oriented

Database connection
<?php 
header(&#39;content-type=text/html;charset=utf-8&#39;);//设置页面html默认字符集为utf-8
$mysqli = new mysqli(&#39;127.0.0.1&#39;,&#39;用户名&#39;,&#39;密码&#39;,&#39;数据库&#39;);//创建MySQLi对象连接数据库
if ($mysqli->connect_errno) {//检测连接错误
	die('连接失败'.$mysqli->connect_error);//输出错误提示符并中断脚本执行
}
$mysqli->set_charset('utf8');//设置默认客户端字符集为utf8
Copy after login
Add data
$sql = "INSERT INTO `tableName` (`field1`,`field2`...) VALUES ('value1','value2'...)";
if ($mysqli->query($sql)) {
	echo '成功添加了'.$mysqli->affected_rows.'条新增记录,新增id是'.$mysqli->insert_id;
} else {
	echo '添加失败'.$mysqli->errno.':'.$mysqli->error;
}
Copy after login
Update data
$sql = "UPDATE `表名` SET `字段名1`='值1' WHERE '条件表达式'";
if ($mysqli->query($sql)) {
	echo '成功更新了'.$mysqli->affected_rows.'条记录';
} else {
	echo '更新失败'.$mysqli->errno.':'.$mysqli->error;
}
Copy after login
Delete data
$sql = "DELETE FROM `表名` WHERE `id`=4";
if ($mysqli->query($sql)) {
	echo '成功删除了'.$mysqli->affected_rows.'条记录';
} else {
	echo '删除失败'.$mysqli->errno.':'.$mysqli->error;
}
Copy after login
Query data
$sql = "SELECT `字段列表` FROM `表名` where '条件表达式'";
if ($mysqli_result=$mysqli->query($sql)) {
	while($row=$mysqli_result->fetch_array(MYSQL_ASSOC)){
		echo '<pre class="brush:php;toolbar:false">';
		print_r($row);
	}
}
Copy after login
$sql = "SELECT `字段列表` FROM `表名` where '条件表达式'";
$result=$mysqli->query($sql)->fetch_array());
Copy after login

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of Is thinkphp object-oriented?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template