bin/php/ezconvertdbcharset.php
File containing the ezconvertdbcharset.php script.
- Copyright
- Copyright (C) 1999-2011 eZ Systems AS. All rights reserved.
- License
- eZ Business Use License Agreement Version 2.0
- Package
- kernel
- Version
- 4.6.0
Constants

EZ_CREATE_CONTENTCLASS_ATTRIBUTE_TMP_TABLE_SQL_MYSQL
= "
CREATE TEMPORARY TABLE " . EZ_CONTENTCLASS_ATTRIBUTE_TMP_TABLE_NAME . " (
id int(11) NOT NULL default '0',
version int(11) NOT NULL default '0',
is_always_available int(11) NOT NULL default '0',
language_locale varchar(20) NOT NULL default '',
name varchar(255) NOT NULL default '',
PRIMARY KEY (id,version,language_locale)
)"

EZ_CREATE_CONTENTCLASS_ATTRIBUTE_TMP_TABLE_SQL_POSTGRESQL
= "
CREATE TABLE " . EZ_CONTENTCLASS_ATTRIBUTE_TMP_TABLE_NAME . " (
id integer DEFAULT 0 NOT NULL,
version integer DEFAULT 0 NOT NULL,
is_always_available integer DEFAULT 0 NOT NULL,
language_locale character varying(20) DEFAULT ''::character varying NOT NULL,
name character varying(255) DEFAULT ''::character varying NOT NULL
)"

EZ_CREATE_CONTENTCLASS_ATTRIBUTE_TMP_TABLE_SQL_ORACLE
= "
CREATE GLOBAL TEMPORARY TABLE " . EZ_CONTENTCLASS_ATTRIBUTE_TMP_TABLE_NAME . " (
id number(11) DEFAULT 0 NOT NULL,
version number(11) DEFAULT 0 NOT NULL,
is_always_available number(11) DEFAULT 0 NOT NULL,
language_locale varchar2(20) NOT NULL,
name varchar2(255) NOT NULL
) ON COMMIT PRESERVE ROWS;"
Functions

changeDBCharsetMYSQL(
$charset, $collation
)
:
void
Name | Type | Description |
---|---|---|
$charset | ||
$collation |

changeDBCharsetORACLE(
$charset, $collation
)
:
void
NOTE: What if other data is also in the db? Either we do not convert it and have it most likely corrupted, or we convert it - and leave to the client for the other apps to set up NLS_LANG correctly to keep working.
We could use the csalter script iff we where sure that db version was > 9...
Oracle 9 exp exports data using the DB charset
From http://www.experts-exchange.com/Database/Oracle/Q_22836430.html
May be the best procedure is the following one: On PROD Database: 1. export full=y rows=n file=export_db_structure.dmp 2. export full=y file=export_db_date.dmp On TEST Database: 1. create tablespaces with the same name on PROD 2. import full=y file=export_db_structure.dmp ignore=y Now we have users of PROD, on TEST database. SYSTEM user is not imported, because already exists. 3. import fromuser=user1,user2,user3 touser=user1,user2,user3 file=export_db_data.dmp ignore=y now we have user1..3 data on their tables...
Unfortunately even if we do that, Oracle will nto let us convert a db from
latin1 to utf8 charsets. The only way is to drop the db and creater it
from scratch. Since we have no clue about db storage, we will let the admin
take care of that part, and only do the export/import parts.
Name | Type | Description |
---|---|---|
$charset | ||
$collation |
- Todo
- oracle servers might use UTF8 charset instead of AL32UTF8: check before executing!
- Todo
- using dbname as file name does not work with easy conection naming
- Todo
- log somewhere results of imp, exp commands for better understanding of errors

changeDBCharsetPOSTGRESQL(
$charset, $collation
)
:
void
Name | Type | Description |
---|---|---|
$charset | ||
$collation |

convertArray(
$array, $inCharset, $outCharset
)
:
void
Name | Type | Description |
---|---|---|
$array | ||
$inCharset | ||
$outCharset |

convertSerializedData(
$serializedDataInfo
)
:
void
Name | Type | Description |
---|---|---|
$serializedDataInfo |

convertXMLData(
$tableInfo, $xmlDataSelectSQLFunction, $xmlDataUpdateSQLFunction, $convertXMLProgressFunction
)
:
void
Name | Type | Description |
---|---|---|
$tableInfo | ||
$xmlDataSelectSQLFunction | ||
$xmlDataUpdateSQLFunction | ||
$convertXMLProgressFunction |

eZExecuteShellCommand(
$command, $errMessage
=
'', $retry
=
true, $ignore
=
false
)
:
void
Name | Type | Description |
---|---|---|
$command | ||
$errMessage | ||
$retry | ||
$ignore |

parseCustomSerializedDataOption(
$serializedCustomDataOption
)
:
void
Name | Type | Description |
---|---|---|
$serializedCustomDataOption |

parseCustomXMLDataOption(
$xmlCustomDataOption
)
:
void
Name | Type | Description |
---|---|---|
$xmlCustomDataOption |

parseXMLAttributesOption(
$xmlAttributesOption
)
:
void
Name | Type | Description |
---|---|---|
$xmlAttributesOption |

removeIllegalUTF8Characters(
$text
)
:
void
For some reason, some utf8 encoded text stored in the db might contain illegal utf8 characters.
This function will strip/replace such known characters
Name | Type | Description |
---|---|---|
$text |

restoreSerializedData(
$serializedDataInfo
)
:
void
Name | Type | Description |
---|---|---|
$serializedDataInfo |

serializeNames(
$selectSQL, $storeToTable
)
:
void
Name | Type | Description |
---|---|---|
$selectSQL | ||
$storeToTable |

showError(
$message, $addEOL
=
true, $bailOut
=
true
)
:
void
Name | Type | Description |
---|---|---|
$message | ||
$addEOL | ||
$bailOut |

storeSerializedName(
$serializedName, $id, $version, $table
)
:
void
Name | Type | Description |
---|---|---|
$serializedName | ||
$id | ||
$version | ||
$table |

xmlCustomDataUpdateSQL(
$dataTableInfo, $row
)
:
void
Name | Type | Description |
---|---|---|
$dataTableInfo | ||
$row |