本文整理汇总了PHP中BasePeer::translateFieldname方法的典型用法代码示例。如果您正苦于以下问题:PHP BasePeer::translateFieldname方法的具体用法?PHP BasePeer::translateFieldname怎么用?PHP BasePeer::translateFieldname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BasePeer
的用法示例。
在下文中一共展示了BasePeer::translateFieldname方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateajaxAction
public function validateajaxAction()
{
$request = $this->getRequest();
if ($request->isPost()) {
$post_data = $request->getPost();
$query = new \ClienteQuery();
$query->filterBy(\BasePeer::translateFieldname('cliente', $post_data['field'], \BasePeer::TYPE_FIELDNAME, \BasePeer::TYPE_PHPNAME), $post_data['value'], \Criteria::EQUAL);
$exist = $query->exists();
if ($post_data['field'] == 'cliente_email') {
$msj = 'correo electrónico en uso';
}
return $this->getResponse()->setContent(json_encode(array('exist' => $exist, 'msj' => $msj)));
}
}
示例2: _update_changes
/**
* Inspect the changes made to $object since its last version (the one stored in the database).
* Update $entry's changes_detail to reflect the changes made.
*
* @param mixed $object
* @param ncChangeLogEntry $entry
*/
protected static function _update_changes($object, ncChangeLogEntry $entry)
{
//hack: remove $object from it's Peer's instance pool before diff is computed
call_user_func(array(get_class($object->getPeer()), 'removeInstanceFromPool'), $object);
$new_values = $object->toArray(BasePeer::TYPE_FIELDNAME);
if (is_array($object->getPrimaryKey())) {
$stored_object = call_user_func_array(array(get_class($object->getPeer()), 'retrieveByPK'), $object->getPrimaryKey());
} else {
$stored_object = call_user_func(array(get_class($object->getPeer()), 'retrieveByPK'), $object->getPrimaryKey());
}
if (!$stored_object) {
// Unable to retrieve object from database: do nothing
return false;
}
$stored_values = $stored_object->toArray(BasePeer::TYPE_FIELDNAME);
$ignored_fields = self::getIgnoredFields(get_class($object));
$dbMap = Propel::getDatabaseMap();
$table = $dbMap->getTable(constant(get_class($object->getPeer()) . '::TABLE_NAME'));
$diff = array('class' => get_class($object), 'pk' => $object->getPrimaryKey(), 'changes' => array());
foreach ($new_values as $key => $value) {
if (in_array($key, $ignored_fields)) {
continue;
} elseif ($value != $stored_values[$key]) {
$column = $table->getColumn(BasePeer::translateFieldname(get_class($object), $key, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_COLNAME));
list($value_method, $params) = self::extractValueMethod($column);
$diff['changes'][$key] = array('old' => $stored_object->{$value_method}($params), 'new' => $object->{$value_method}($params), 'field' => $key, 'raw' => array('old' => $stored_values[$key], 'new' => $value));
}
}
if (isset($diff['changes']) && empty($diff['changes'])) {
return false;
}
$entry->setChangesDetail(base64_encode(serialize($diff)));
return true;
}