本文整理汇总了PHP中Phalcon\Mvc\Model类的典型用法代码示例。如果您正苦于以下问题:PHP Model类的具体用法?PHP Model怎么用?PHP Model使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Model类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getErrorMessages
/**
* Modelのエラーメッセージを取得
* @return array
*/
public function getErrorMessages()
{
foreach ($this->model->getMessages() as $msgs) {
$errMsgs[] = $msgs->getMessage();
}
return $errMsgs;
}
示例2: showModelErrors
public function showModelErrors(Model $model, Form $form)
{
foreach ($model->getMessages() as $message) {
$fieldName = $message->getField();
$form->addModelError($fieldName, $message->getMessage());
}
}
示例3: createModelErrorMessages
/**
* Recebe um model e une as excessões para retornar em texto
*
* @param \Phalcon\Mvc\Model $model
* @return string
*/
public static function createModelErrorMessages(\Phalcon\Mvc\Model $model)
{
$excepts = [];
foreach ($model->getMessages() as $message) {
$excepts[] = $message;
}
return implode("\n", $excepts);
}
示例4: databaseErrorLog
/**
* 数据库操作异常
* @param \Phalcon\Mvc\Model $model
* @return bool
*/
public function databaseErrorLog($model)
{
$error = '';
foreach ($model->getMessages() as $msg) {
$error .= $msg . ',';
}
$this->di->get('logger')->error('数据库异常, GET:' . json_encode($_GET) . ', POST:' . json_encode($_POST) . ', error: ' . $error);
return false;
}
示例5: logDatabaseError
/**
* 数据库操作异常
* @param \Phalcon\Mvc\Model $model
*/
public function logDatabaseError($model)
{
if ($this->di->offsetExists('logger') == false) {
return;
}
$error = '';
foreach ($model->getMessages() as $msg) {
$error .= $msg . ',';
}
$this->di->get('logger')->error('数据库异常, GET:' . json_encode($_GET) . ', POST: ' . json_encode($_POST) . ', error: ' . $error);
}
示例6: findFirst
public static function findFirst($parameters = NULL, $hostType = NULL)
{
$class = get_called_class();
$object = new $class();
BaseModel::$tableName = $object->getSource();
BaseModel::$hostType = $hostType;
return parent::findFirst($parameters);
}
示例7: getMessages
/**
* @param bool $bAsString
* @return \Phalcon\Mvc\Model\MessageInterface[]|string
*/
public function getMessages($bAsString = false)
{
if (!$bAsString) {
return parent::getMessages();
} else {
return implode(', ', parent::getMessages());
}
}
示例8: delete
public function delete()
{
foreach ($this->IgoListeValeur as $liste) {
$liste->delete();
}
return parent::delete();
}
示例9: getMessages
/**
* Replace/translate default messages generated by the ORM.
*
* @return array
*/
public function getMessages()
{
foreach (parent::getMessages() as $message) {
switch ($message->getType()) {
case 'PresenceOf':
$message->setMessage('The field ' . $message->getField() . ' is required');
break;
case 'Uniqueness':
$message->setMessage('The field ' . $message->getField() . ' must be unique');
break;
case 'Email':
$message->setMessage('The field ' . $message->getField() . ' must contain a valid email');
break;
case 'Url':
$message->setMessage('The field ' . $message->getField() . ' must contain a valid url');
break;
case 'InclusionIn':
$message->setMessage('The field ' . $message->getField() . ' must contain a value in [' . implode(',', $message->getDomain()) . ']');
break;
case 'DateValidator':
$message->setMessage('The field ' . $message->getField() . ' must contain a valid date.');
break;
case 'TimestampValidator':
$message->setMessage('The field ' . $message->getField() . ' must contain a valid timestamps.');
break;
}
}
return parent::getMessages();
}
示例10: __callStatic
public static function __callStatic($name, $parameters = null)
{
if (0 === strpos($name, 'has')) {
return static::hasColumnValue(Str::convertSnake(substr($name, 3)), $parameters[0]);
}
return parent::__callStatic($name, $parameters);
}
示例11: __set
public function __set($property, $value)
{
if (is_object($property) || is_array($property)) {
return parent::__set($property, $value);
}
$this->_dataAccess[$property] = $value;
}
示例12: __set
public function __set($fieldName, $value)
{
// Check if the property is public
try {
$R = new \ReflectionClass($this);
$property = $R->getProperty($fieldName);
} catch (\ReflectionException $e) {
// Property doesn't exist, call the stupid parent
return parent::__set($fieldName, $value);
}
if ($property->isPublic()) {
// Again, call your parents
return parent::__set($fieldName, $value);
} else {
// Property exists, and it's private / protected
try {
// Maybe there is a setter for this one?
$nameArr = explode('_', $fieldName);
$methodName = 'set';
foreach ($nameArr as $vv) {
$methodName .= ucwords($vv);
}
$method = $R->getMethod($methodName);
// Okay, no exception, let's call it
return $this->{$methodName}($value);
} catch (\ReflectionException $up) {
// Just let it go through
throw $up;
}
}
}
示例13: delete
public function delete()
{
foreach ($this->IgoGeometrie as $geometrie) {
$geometrie->delete();
}
return parent::delete();
}
示例14: findFirst
/**
* Caches models data in memory
*
* @param mixed $parameters
* @return $this
*/
public static function findFirst($parameters = null)
{
// Create an unique key based on the parameters
if ($key = self::createKey($parameters)) {
$parameters['cache'] = ['key' => $key];
}
return parent::findFirst($parameters);
}
示例15: save
public function save($saveMapFile = true, $data = NULL, $whiteList = NULL)
{
$retour = parent::save($data, $whiteList);
if ($saveMapFile && $this->IgoCouche->IgoGeometrie->acces == "L") {
$this->IgoCouche->save();
}
return $retour;
}