FOSSology  4.4.0
Open Source License Compliance by Open Source Software
dbmigrate_copyright-author.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2017 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
16 $countAuthorColumns = $dbManager->getSingleRow("SELECT count(*) FROM copyright WHERE type <> 'statement' AND content IS NOT NULL;",array(),'getCountAuthorColumns');
17 
18 if($countAuthorColumns['count'] > 0){
19 
20  echo "Insert email/url/author data from copyright to author table... \nIt takes some time depending number of columns... \n";
21 
22  $dbManager->queryOnce("INSERT INTO author (agent_fk, pfile_fk, content, hash, type, copy_startbyte, copy_endbyte, is_enabled)
23  SELECT agent_fk, pfile_fk, content, hash, type, copy_startbyte, copy_endbyte, is_enabled
24  FROM copyright WHERE type <> 'statement' AND content IS NOT NULL;");
25  $countInsertedAuthorColumns = $dbManager->getSingleRow("SELECT count(*) FROM author au INNER JOIN copyright co
26  ON au.pfile_fk = co.pfile_fk WHERE au.author_pk = co.copyright_pk AND au.content = co.content;",array(),'getCountInsertedAuthorColumns');
27  if($countAuthorColumns['count'] == $countInsertedAuthorColumns['count']){
28  echo "Deleting the email/url/author data from copyright table...\n";
29  $dbManager->queryOnce("DELETE FROM copyright WHERE type <> 'statement' AND content IS NOT NULL;");
30  } else {
31  echo "Something went wrong please execute the postinstall again...\n";
32  }
33 }