本文整理汇总了PHP中QConvertNotation::CamelCaseFromUnderscore方法的典型用法代码示例。如果您正苦于以下问题:PHP QConvertNotation::CamelCaseFromUnderscore方法的具体用法?PHP QConvertNotation::CamelCaseFromUnderscore怎么用?PHP QConvertNotation::CamelCaseFromUnderscore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QConvertNotation
的用法示例。
在下文中一共展示了QConvertNotation::CamelCaseFromUnderscore方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CalculateObjectDescriptionForAssociation
protected function CalculateObjectDescriptionForAssociation($strAssociationTableName, $strTableName, $strReferencedTableName, $blnPluralize)
{
// Strip Prefixes (if applicable)
$strTableName = $this->StripPrefixFromTable($strTableName);
$strAssociationTableName = $this->StripPrefixFromTable($strAssociationTableName);
$strReferencedTableName = $this->StripPrefixFromTable($strReferencedTableName);
// Starting Point
$strToReturn = QConvertNotation::CamelCaseFromUnderscore($strReferencedTableName);
if ($blnPluralize) {
$strToReturn = $this->Pluralize($strToReturn);
}
// Let's start with strAssociationTableName
// Rip out trailing "_assn" if applicable
$strAssociationTableName = str_replace($this->strAssociationTableSuffix, '', $strAssociationTableName);
// Take out strTableName if applicable (both with and without underscores)
$strAssociationTableName = str_replace($strTableName, '', $strAssociationTableName);
$strTableName = str_replace('_', '', $strTableName);
$strAssociationTableName = str_replace($strTableName, '', $strAssociationTableName);
// Take out strReferencedTableName if applicable (both with and without underscores)
$strAssociationTableName = str_replace($strReferencedTableName, '', $strAssociationTableName);
$strReferencedTableName = str_replace('_', '', $strReferencedTableName);
$strAssociationTableName = str_replace($strReferencedTableName, '', $strAssociationTableName);
// Change any double "__" to single "_"
$strAssociationTableName = str_replace("__", "_", $strAssociationTableName);
$strAssociationTableName = str_replace("__", "_", $strAssociationTableName);
$strAssociationTableName = str_replace("__", "_", $strAssociationTableName);
// If we have nothing left or just a single "_" in AssociationTableName, return "Starting Point"
if ($strAssociationTableName == "_" || $strAssociationTableName == "") {
return sprintf("%s%s%s", $this->strAssociatedObjectPrefix, $strToReturn, $this->strAssociatedObjectSuffix);
}
// Otherwise, add "As" and the predicate
return sprintf("%s%sAs%s%s", $this->strAssociatedObjectPrefix, $strToReturn, QConvertNotation::CamelCaseFromUnderscore($strAssociationTableName), $this->strAssociatedObjectSuffix);
}
示例2: CalculateObjectDescriptionForAssociation
protected function CalculateObjectDescriptionForAssociation($strAssociationTableName, $strTableName, $strReferencedTableName, $blnPluralize)
{
// Strip Prefixes (if applicable)
$strTableName = $this->StripPrefixFromTable($strTableName);
$strAssociationTableName = $this->StripPrefixFromTable($strAssociationTableName);
$strReferencedTableName = $this->StripPrefixFromTable($strReferencedTableName);
// Starting Point
$strToReturn = QConvertNotation::CamelCaseFromUnderscore($strReferencedTableName);
if ($blnPluralize) {
$strToReturn = $this->Pluralize($strToReturn);
}
// Let's start with strAssociationTableName
// Rip out trailing "_assn" if applicable
$strAssociationTableName = str_replace($this->strAssociationTableSuffix, '', $strAssociationTableName);
// remove instances of the table names in the association table name
$strTableName2 = str_replace('_', '', $strTableName);
// remove underscores if they are there
$strReferencedTableName2 = str_replace('_', '', $strReferencedTableName);
// remove underscores if they are there
if (beginsWith($strAssociationTableName, $strTableName . '_')) {
$strAssociationTableName = trimOffFront($strTableName . '_', $strAssociationTableName);
} elseif (beginsWith($strAssociationTableName, $strTableName2 . '_')) {
$strAssociationTableName = trimOffFront($strTableName2 . '_', $strAssociationTableName);
} elseif (beginsWith($strAssociationTableName, $strReferencedTableName . '_')) {
$strAssociationTableName = trimOffFront($strReferencedTableName . '_', $strAssociationTableName);
} elseif (beginsWith($strAssociationTableName, $strReferencedTableName2 . '_')) {
$strAssociationTableName = trimOffFront($strReferencedTableName2 . '_', $strAssociationTableName);
} elseif ($strAssociationTableName == $strTableName || $strAssociationTableName == $strTableName2 || $strAssociationTableName == $strReferencedTableName || $strAssociationTableName == $strReferencedTableName2) {
$strAssociationTableName = "";
}
if (endsWith($strAssociationTableName, '_' . $strTableName)) {
$strAssociationTableName = trimOffEnd('_' . $strTableName, $strAssociationTableName);
} elseif (endsWith($strAssociationTableName, '_' . $strTableName2)) {
$strAssociationTableName = trimOffEnd('_' . $strTableName2, $strAssociationTableName);
} elseif (endsWith($strAssociationTableName, '_' . $strReferencedTableName)) {
$strAssociationTableName = trimOffEnd('_' . $strReferencedTableName, $strAssociationTableName);
} elseif (endsWith($strAssociationTableName, '_' . $strReferencedTableName2)) {
$strAssociationTableName = trimOffEnd('_' . $strReferencedTableName2, $strAssociationTableName);
} elseif ($strAssociationTableName == $strTableName || $strAssociationTableName == $strTableName2 || $strAssociationTableName == $strReferencedTableName || $strAssociationTableName == $strReferencedTableName2) {
$strAssociationTableName = "";
}
// Change any double "__" to single "_"
$strAssociationTableName = str_replace("__", "_", $strAssociationTableName);
$strAssociationTableName = str_replace("__", "_", $strAssociationTableName);
$strAssociationTableName = str_replace("__", "_", $strAssociationTableName);
// If we have nothing left or just a single "_" in AssociationTableName, return "Starting Point"
if ($strAssociationTableName == "_" || $strAssociationTableName == "") {
return sprintf("%s%s%s", $this->strAssociatedObjectPrefix, $strToReturn, $this->strAssociatedObjectSuffix);
}
// Otherwise, add "As" and the predicate
return sprintf("%s%sAs%s%s", $this->strAssociatedObjectPrefix, $strToReturn, QConvertNotation::CamelCaseFromUnderscore($strAssociationTableName), $this->strAssociatedObjectSuffix);
}
示例3: JavaCaseFromUnderscore
public static function JavaCaseFromUnderscore($strName)
{
$strToReturn = QConvertNotation::CamelCaseFromUnderscore($strName);
return strtolower(substr($strToReturn, 0, 1)) . substr($strToReturn, 1);
}
示例4: AnalyzeTable
protected function AnalyzeTable(QTable $objTable)
{
// Setup the Table Object
$strTableName = $objTable->Name;
$objTable->ClassName = $this->ClassNameFromTableName($strTableName);
$objTable->ClassNamePlural = $this->Pluralize($objTable->ClassName);
$objTable->BaseClassName = $this->BaseClassNameFromTableName($strTableName);
$objTable->FileName = QConvertNotation::CamelCaseFromUnderscore($this->StripPrefixFromTable($strTableName));
// Get the List of Columns
$objFieldArray = $this->objDb->GetFieldsForTable($strTableName);
// Iterate through the list of Columns to create objColumnArray
$objColumnArray = array();
if ($objFieldArray) {
foreach ($objFieldArray as $objField) {
$objColumn = $this->AnalyzeTableColumn($objField, $objTable);
if ($objColumn) {
$objColumnArray[strtolower($objColumn->Name)] = $objColumn;
}
}
}
$objTable->ColumnArray = $objColumnArray;
// Get the List of Indexes
$objTable->IndexArray = $this->objDb->GetIndexesForTable($objTable->Name);
// Create an Index array
$objIndexArray = array();
// Create our Index for Primary Key (if applicable)
$strPrimaryKeyArray = array();
foreach ($objColumnArray as $objColumn) {
if ($objColumn->PrimaryKey) {
$objPkColumn = $objColumn;
array_push($strPrimaryKeyArray, $objColumn->Name);
}
}
if (count($strPrimaryKeyArray)) {
$objIndex = new QIndex();
$objIndex->KeyName = 'pk_' . $strTableName;
$objIndex->PrimaryKey = true;
$objIndex->Unique = true;
$objIndex->ColumnNameArray = $strPrimaryKeyArray;
array_push($objIndexArray, $objIndex);
if (count($strPrimaryKeyArray) == 1) {
$objPkColumn->Unique = true;
$objPkColumn->Indexed = true;
}
}
// Iterate though each Index that exists in this table, set any Columns's "Index" property
// to TRUE if they are a single-column index
if ($objTable->IndexArray) {
foreach ($objArray = $objTable->IndexArray as $objDatabaseIndex) {
// Make sure the columns are defined
if (count($objDatabaseIndex->ColumnNameArray) == 0) {
$this->strErrors .= sprintf("Index %s in table %s indexes on no columns.\n", $objDatabaseIndex->KeyName, $strTableName);
} else {
// Ensure every column exist in the DbIndex's ColumnNameArray
$blnFailed = false;
foreach ($objArray = $objDatabaseIndex->ColumnNameArray as $strColumnName) {
if (array_key_exists(strtolower($strColumnName), $objTable->ColumnArray) && $objTable->ColumnArray[strtolower($strColumnName)]) {
// It exists -- do nothing
} else {
// Otherwise, add a warning
$this->strErrors .= sprintf("Index %s in table %s indexes on the column %s, which does not appear to exist.\n", $objDatabaseIndex->KeyName, $strTableName, $strColumnName);
$blnFailed = true;
}
}
if (!$blnFailed) {
// Let's make sure if this is a single-column index, we haven't already created a single-column index for this column
$blnAlreadyCreated = false;
foreach ($objIndexArray as $objIndex) {
if (count($objIndex->ColumnNameArray) == count($objDatabaseIndex->ColumnNameArray)) {
if (implode(',', $objIndex->ColumnNameArray) == implode(',', $objDatabaseIndex->ColumnNameArray)) {
$blnAlreadyCreated = true;
}
}
}
if (!$blnAlreadyCreated) {
// Create the Index Object
$objIndex = new QIndex();
$objIndex->KeyName = $objDatabaseIndex->KeyName;
$objIndex->PrimaryKey = $objDatabaseIndex->PrimaryKey;
$objIndex->Unique = $objDatabaseIndex->Unique;
if ($objDatabaseIndex->PrimaryKey) {
$objIndex->Unique = true;
}
$objIndex->ColumnNameArray = $objDatabaseIndex->ColumnNameArray;
// Add the new index object to the index array
array_push($objIndexArray, $objIndex);
// Lastly, if it's a single-column index, update the Column in the table to reflect this
if (count($objDatabaseIndex->ColumnNameArray) == 1) {
$strColumnName = $objDatabaseIndex->ColumnNameArray[0];
$objColumn = $objTable->ColumnArray[strtolower($strColumnName)];
$objColumn->Indexed = true;
if ($objIndex->Unique) {
$objColumn->Unique = true;
}
}
}
}
}
}
}
//.........这里部分代码省略.........