Home Backend Development PHP Tutorial A simple database traceback

A simple database traceback

Jul 29, 2016 am 09:11 AM
database db default master

Introduction. I checked the code today and flew all the way to the database.

<span>1</span><span>$this->slave()->select('sina_user_id, sina_nickname, password')->from(self::Table_User_Info)</span>
Copy after login

Obviously the table .user_info has been determined here;

This file is not loaded->database();

As the name: slave() is from Library, trace slave(). Sure enough, the library name string is combined here,

<span>1</span><span>    public function slave($dbName = 'default')
</span><span>2</span>     { 
<span>3</span>     }
Copy after login

func. Inside load->database();

Check database() in loader; there is the following sentence,

<span>1</span><span><strong>require</strong>_once(BASEPATH.'database/DB.php');</span>
Copy after login

Find DB.php;

<span>1</span><span>    if ( ! defined('ENVIRONMENT') OR ! file_exists($file_path = BASEPATH.'config/'.ENVIRONMENT.'/database.php'))</span>
Copy after login

The introduction of multiple database attributes in this file, see core file analysis for details.

Finally found the location of database.php

<span> 1</span><span>// Default DB Config
</span><span> 2</span><span>$db['default_master']['hostname'] = 'localhost';
</span><span> 3</span><span>$db['default_master']['username'] = 'admin';
</span><span> 4</span><span>$db['default_master']['password'] = '12345678';
</span><span> 5</span><span>$db['default_master']['database'] = ' ';
</span><span> 6</span><span>$db['default_master']['port'] = 3306;
</span><span> 7</span><span>$db['default_master']['dbdriver'] = 'mysql';
</span><span> 8</span><span>$db['default_master']['pconnect'] = FALSE;
</span><span> 9</span><span>$db['default_master']['db_debug'] = TRUE;
</span><span>10</span><span>$db['default_master']['cache_on'] = FALSE;
</span><span>11</span><span>$db['default_master']['cachedir'] = '';
</span><span>12</span><span>$db['default_master']['char_set'] = 'utf8';
</span><span>13</span><span>$db['default_master']['dbcollat'] = 'utf8_general_ci';
</span><span>14</span><span>$db['default_master']['swap_pre'] = '';
</span><span>15</span><span>$db['default_master']['autoinit'] = TRUE;
</span><span>16</span><span>$db['default_master']['stricton'] = FALSE;</span>
Copy after login

Tracing the database is completed.

The above introduces a simple database tracing, including the require content. I hope it will be helpful to friends who are interested in PHP tutorials.

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1666
14
PHP Tutorial
1273
29
C# Tutorial
1254
24
How to solve discuz database error How to solve discuz database error Nov 20, 2023 am 10:10 AM

The solutions to discuz database error are: 1. Check the database configuration; 2. Make sure the database server is running; 3. Check the database table status; 4. Back up the data; 5. Clear the cache; 6. Reinstall Discuz; 7. Check the server resources ; 8. Contact Discuz official support. Solving Discuz database errors requires starting from multiple aspects, gradually identifying the cause of the problem, and taking corresponding measures to repair it.

Leak reveals key specs of Intel Arrow Lake-U, -H, -HX and -S Leak reveals key specs of Intel Arrow Lake-U, -H, -HX and -S Jun 15, 2024 pm 09:49 PM

IntelArrowLakeisexpectedtobebasedonthesameprocessorarchitectureasLunarLake,meaningthatIntel'sbrandnewLionCoveperformancecoreswillbecombinedwiththeeconomicalSkymontefficiencycores.WhileLunarLakeisonlyavailableasava

What is the difference between master and host What is the difference between master and host Sep 28, 2023 pm 01:34 PM

The differences between master and host are: 1. Host can play the role of client or server, while master is the central server responsible for coordinating and managing other slave servers in a distributed system; 2. Host is an ordinary computer device, and master usually has Higher processing power and resources are used to process and distribute tasks, manage data, and maintain the stability of the entire system; 3. The host is a node in the network, and the master is the server that plays a core role in the distributed system.

Comparative analysis of Oracle and DB2 database technology Comparative analysis of Oracle and DB2 database technology Mar 11, 2024 am 09:54 AM

Oracle and DB2 are two well-known relational database management systems (RDBMS) that are widely used in enterprise applications. In this article, we will compare the two database technologies of Oracle and DB2 and analyze them in detail, including analysis of their characteristics, performance, functions and usage examples. 1. Overview of Oracle database technology Oracle is a relational database management system developed by Oracle Corporation of the United States. It is widely used in enterprise-level applications and has strong performance and stability.

Comparison and differences of SQL syntax between Oracle and DB2 Comparison and differences of SQL syntax between Oracle and DB2 Mar 11, 2024 pm 12:09 PM

Oracle and DB2 are two commonly used relational database management systems, each of which has its own unique SQL syntax and characteristics. This article will compare and differ between the SQL syntax of Oracle and DB2, and provide specific code examples. Database connection In Oracle, use the following statement to connect to the database: CONNECTusername/password@database. In DB2, the statement to connect to the database is as follows: CONNECTTOdataba

Comparative analysis of Oracle and DB2 database performance Comparative analysis of Oracle and DB2 database performance Mar 09, 2024 pm 10:00 PM

Oracle and DB2 databases are two leading relational database management systems that are widely used in enterprise-level applications. In practical applications, database performance is often one of the important indicators for evaluating the quality of a database system. This article will conduct a comparative analysis of the performance of Oracle and DB2 databases, and use specific code examples to demonstrate the differences between them. 1. Oracle database performance analysis Oracle database is a powerful database management system with good scalability and stability.

What file format is db? What file format is db? May 19, 2021 am 11:56 AM

db is the abbreviation of "datebase", which is a format of "database file". It is a file used by software to store data, which is equivalent to a database. Each software has its own storage format. For example, "Thumbs.db" under Win7 system is a thumbnail data file, so the db file is not a specific file format.

What is the file format of db? What is the file format of db? Mar 07, 2023 pm 05:27 PM

db is a database file format, which is a file used by software to store data. It is equivalent to a database. Each software has its own storage format, that is, the way the data is arranged; the suffix of some software data files is DB. For example, Thumbs.db under Win7 system is a thumbnail data file; therefore, the db file is not a specific file format.

See all articles