- Joomla! 1.5x Customization: Make Your Site Adapt to Your Needs
- Daniel Chapman
- 502字
- 2021-04-01 13:53:15
Database work with MySQL and SQL
Jumping back to the server, an understanding the technologies behind Joomla! can't be considered complete without a discussion on Structured Query Language (SQL). SQL is the language of choice for most databases, and anytime we want to add or retrieve data from the database of a Joomla! site, we will need to do it via SQL.
SQL is a relatively straightforward and simple language to pick up, but it can get quite complex at higher levels of development. It is designed purely to interact with data in a database and can do very little else.
The four most common SQL commands we will use are:
SELECT
INSERT
UPDATE
DELETE
There are others, but these are the ones we will need to know most.
Following one of these initial commands will usually be a preposition and a table name. Or it could be a comma separated list of columns, then the proposition and table name and is written in fairly easy to understand language. For example:
SELECT name, address FROM person_table … INSERT INTO person_table … UPDATE person_table … DELETE FROM person_table …
For SELECT, UPDATE
, and DELETE
, there will also usually be a WHERE
clause that provides the criteria upon which to do the search.
SELECT name, address FROM person_table WHERE age > "16" UPDATE person_table … WHERE name = "John Doe" DELETE FROM person_table WHERE name = "John Doe"
For INSERT
queries, there will also be a set of values to insert, and possibly a list of columns to INSERT INTO
.
INSERT INTO person_table (name, address, age) VALUES ( "John Doe","10 This St, Atown","25")
For UPDATE
queries, they are again a little different, but easy to understand.
UPDATE person_table SET address="25 Anew St, Atown" WHERE name = "John Doe"
Something we will sometimes see with SELECT
statements is the use of an asterix (*) character in place of a column list. This is shorthand to indicate that we want to use all of the available columns, arranged in the same order as they appear in the database.
SELECT * FROM person_table WHERE age > "16"
Something we will quickly notice if we are looking over existing Joomla! database queries is that almost all of them will have a hash and two underscores before the table name. For example:
SELECT * FROM #__person_table
This hash underscore is replaced at run time with the current database prefix. So #__person_table
will be converted into something similar to jos_person_table
by the Joomla! database functions when they run the query.
The database prefix exists to allow people to install multiple Joomla! sites and use the same database for all of them, without the data for each one overwriting the others. The different sites can then just use different prefixes, and that way they keep all their data in separate tables.
Note
As with all of our programming topics, there is a lot more useful information available on the Internet regarding MySQL and the SQL programming language (sites such as http://www.w3schools.com/SQl/default.asp).
- UG NX 12.0中文版完全自學(xué)一本通
- 突破平面Premiere Pro 2022短視頻與視頻制作
- AutoCAD Civil 3D 2018 場地設(shè)計實例教程
- CorelDRAW服裝設(shè)計實用教程(第四版)
- 中文版CorelDRAW X6基礎(chǔ)培訓(xùn)教程
- 中文版AutoCAD基礎(chǔ)培訓(xùn)教程
- AutoCAD 2019中文版計算機輔助繪圖全攻略
- 綁定的藝術(shù):Maya高級角色骨骼綁定技法(第2版)
- Blender 2.5 Materials and Textures Cookbook
- CAXA電子圖板2016基礎(chǔ)與實例教程
- Plone 3 for Education
- AI繪畫與攝影實戰(zhàn)108招:ChatGPT+Midjourney+文心一格
- Science Teaching with Moodle 2.0
- Photoshop后期強:攝影后期影調(diào)與調(diào)色實戰(zhàn)寶典
- UG NX 6.0入門與提高