Connect to databases, execute queries, and manipulate data in Concrete CMS projects. Use this skill when the user asks to build custom block types or connect with database.
Installation
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Connect to databases, execute queries, and manipulate data in Concrete CMS projects. Use this skill when the user asks to build custom block types or connect with database.
Working with Database
How to connect
Use $db = $this->app->make(\Concrete\Core\Database\Connection\Connection::class); Do not use the Database facade, it is deprecated.
Here's an example with all the features offered by Doctrine XML:
<?xml version="1.0" encoding="UTF-8"?><schemaxmlns="http://www.concrete5.org/doctrine-xml/0.5"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.concrete5.org/doctrine-xml/0.5
https://concretecms.github.io/doctrine-xml/doctrine-xml-0.5.xsd"
><tablename="Companies"comment="List of companies"><fieldname="Id"type="integer"comment="Record identifier"><unsigned/><autoincrement/><key/></field><fieldname="Name"type="string"size="50"comment="Company name"><notnull/><optfor="mysql"collation="utf8_bin"/></field><optfor="mysql"engine="InnoDB"charset="utf8"collate="utf8_unicode_ci"row_format="compact"/></table><tablename="Employees"><fieldname="Id"type="integer"><unsigned/><autoincrement/><key/></field><fieldname="IdentificationCode"type="string"size="20"><fixed/></field><fieldname="Company"type="integer"><unsigned/><notnull/></field><fieldname="FirstName"type="string"size="50"><defaultvalue=""/><notnull/></field><fieldname="LastName"type="string"size="50"><notnull/></field><fieldname="Income"type="decimal"size="10.2"><defaultvalue="1000"/></field><fieldname="HiredOn"type="datetime"><deftimestamp/></field><index><fulltext/><col>FirstName</col></index><indexname="IX_EmployeesIdentificationCode"><unique/><col>IdentificationCode</col></index><referencestable="Companies"onupdate="cascade"ondelete="restrict"><columnlocal="Company"foreign="Id"/></references></table></schema>
AXMLS (Adodb-xmlschema, using <schema version="0.3"></schema>) is a legacy format, so do not use it for new code. No need to refactor XML files already exists.
Best Practices
Avoid using SQL reserved words (especially in MySQL 8+) for column names. For example, lead is reserved in MySQL 8 — do not use it as a column name. Prefer alternatives like summary.