Retrieve sql statements from Module Deploy

Hello everyone !
I’d like to know if exists a way to retrieve sql staments (Create XX or Alter Table XX) that occure when a new module is deployed or when we add|update fields.

Thanks in advance !

@Z4RD0Z

Look at the documentation Module Installer :: SuiteCRM Documentation . You can create scripts „pre_install.php” or „post_install.php’”.

Thanks for the reply, but if I use module builder for create/update modules and simple do Deploy(without export in zip package)? Manifest is going to be overridden because it create from MBPackage.php; also how can I retrieve the sql created from beam/vardefs?

@Z4RD0Z

You can open zip archive, change manifest.php and add script file to archive.

Ok, I’ll try thanks, but the real question is: does exists a easy way to retrieve sql statement from Vardefs o from bean ?

@Z4RD0Z

Yes. It’s possible. Each bean has a $this->db object, and you could write something like this:

$sql = "<your_sql_request>";
$result = $this->db->query($sql);
while ($row = $this->db->fetchByAssoc($result)) {
    ... // your code where $row is array 
}

You can generate new object also:

$db = DBManagerFactory::getInstance();

Yes, I know this, let me explain my issue in a better way: when SuiteCRM installs new module , it creates new table in my db, in agreement with data in vardefs, does exist a simple way to retrieve the Create Table statement that runs?

@Z4RD0Z

Yes. You can override the create_tables() function for each bean.