本文整理汇总了PHP中Translation::setTrnId方法的典型用法代码示例。如果您正苦于以下问题:PHP Translation::setTrnId方法的具体用法?PHP Translation::setTrnId怎么用?PHP Translation::setTrnId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Translation
的用法示例。
在下文中一共展示了Translation::setTrnId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: post
/**
* Implementation for 'POST' method for Rest API
*
* @param mixed $trnCategory, $trnId, $trnLang Primary key
*
* @return array $result Returns array within multiple records or a single record depending if
* a single selection was requested passing id(s) as param
*/
protected function post($trnCategory, $trnId, $trnLang, $trnValue, $trnUpdateDate)
{
try {
$result = array();
$obj = new Translation();
$obj->setTrnCategory($trnCategory);
$obj->setTrnId($trnId);
$obj->setTrnLang($trnLang);
$obj->setTrnValue($trnValue);
$obj->setTrnUpdateDate($trnUpdateDate);
$obj->save();
} catch (Exception $e) {
throw new RestException(412, $e->getMessage());
}
}
示例2: addTranslation
/**
* returns an array with
* codError 0 - no error, < 0 error
* rowsAffected 0,1 the number of rows affected
* message message error.
*/
function addTranslation($category, $id, $languageId, $value)
{
//if exists the row in the database propel will update it, otherwise will insert.
$tr = TranslationPeer::retrieveByPK($category, $id, $languageId);
if (!(is_object($tr) && get_class($tr) == 'Translation')) {
$tr = new Translation();
}
$tr->setTrnCategory($category);
$tr->setTrnId($id);
$tr->setTrnLang($languageId);
$tr->setTrnValue($value);
$tr->setTrnUpdateDate(date('Y-m-d'));
if ($tr->validate()) {
// we save it, since we get no validation errors, or do whatever else you like.
$res = $tr->save();
} else {
// Something went wrong. We can now get the validationFailures and handle them.
$msg = '';
$validationFailuresArray = $tr->getValidationFailures();
foreach ($validationFailuresArray as $objValidationFailure) {
$msg .= $objValidationFailure->getMessage() . "\n";
}
return array('codError' => -100, 'rowsAffected' => 0, 'message' => $msg);
}
return array('codError' => 0, 'rowsAffected' => $res, 'message' => '');
//to do: uniform coderror structures for all classes
}