[Solved] Concrete Insert data into table during package installation

Hello everyone,
during the installation of a packet created by me, I'm using the db.xml to create new tables in the database. This works quite well so far.

But I want to fill the new tables with the some date during the installation of the package.

Here's what I've tried:

1. db.xml query instructions
<?xml version="1.0"?>
<schema version="0.3">
   <table name="cs_test">
      <field name="TestID" type="I" />
      <field name="TestValue" type="C" size="200" />
      <query>INSERT INTO cs_test (TestID, TestValue) VALUES ('1', 'Hello World')</query>

The installation of the packet is successful, but there are no data in the table.

2. SQL statements during installation in the controller
namespace Concrete\Package\CSTest;
use SinglePage;
use Database;
   class Controller extends \Concrete\Core\Package\Package {
      protected $pkgHandle = 'cstest';
      protected $appVersionRequired = '5.7.3';
      protected $pkgVersion = '0.0.1';
      public function getPackageDescription() {
         return t('This is the description of the test package.');
      public function getPackageName() {
         return t('Test Package Name');
      public function install() {
         $pkg = parent::install();

The installation of the packet is successful, but there are no data in the table.

I tried it with the version 5.7.3 and both unfortunately unsuccessful.

What exactly do I have to do to fill the tables with data during installation?

Preliminary ever thank you for your help and sorry for my bad english.


View Replies: View Best Answer
axiandev replied on at Permalink Reply
I'm having this same issue and the documentation on block development in 5.7 continues to be "lacking" (to put it kindly).

It seems like the core Package class's installDB method only really cares about DDL and no DML.

Anyone out there having any luck?
axiandev replied on at Permalink Reply
I added some code to the /concrete/src/Package/Package.php file -

$dbxml = simplexml_load_file($xmlFile);
foreach($dbxml->sql as $sql) {
   foreach($sql->query as $query) {

That seems to have taken care of some of the additional SQL I'd like to execute in my db.xml upon package installation.
rockface replied on at Permalink Reply
Thanks axiandev,

I added your code in the installDB() function, just before "$db->commit();"
Also added ""use Loader;" (thanks Andrew)
Works like a champ!

How long does it take for a code fix to work it's way into a production release?
I have a new block ready for the marketplace, but having it's support data is critical to it's operation. It will need to sit on the shelf until Concrete5 can load data during a package install.
fudyartanto replied on at Permalink Reply
Same issue. bugs..? in concrete 5.6 query statement work fine but when migrating to 5.7 not work and need execute manually in package controller.
andrew replied on at Permalink Best Answer Reply
I didn't even know ADODB let you execute queries in AXMLS with a <sql> XML node. That will not work in our updated compatibility version.

Your second example, however, should totally work. At a glance, though, it looks like you're never importing the "Loader" class. If you had use Loader; at the top of the script that would fix it.
LennDa replied on at Permalink Reply
Thank you for your help. With use Loader everything works fine. Solved