本文整理汇总了PHP中Models类的典型用法代码示例。如果您正苦于以下问题:PHP Models类的具体用法?PHP Models怎么用?PHP Models使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Models类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getReplaceChars
function getReplaceChars($object, $name = "")
{
switch ($name) {
case "products":
return array("%%ID%%" => $object->getId(), "%%NAME%%" => $object->getName(), "%%DESCRIPTION%%" => $object->getDescription(), "%%PICTURE%%" => $object->getPicture());
break;
case "gallery":
return array("%%ID%%" => $object->getId(), "%%NAME%%" => $object->getName(), "%%DESCRIPTION%%" => $object->getDescription(), "%%PICTURE%%" => $object->getFirstPicture(), "%%LIEN%%" => Functions::getDefaultURL() . "portfolio/" . $object->getId() . "_" . str_replace(" ", "_", $object->getName()));
break;
case "improve":
return array("%%ID%%" => $object->getId(), "%%NAME%%" => $object->getName(), "%%CONTENT%%" => $object->getContent(), "%%PICTURE%%" => $object->getPicture());
break;
case "improve1":
return array("%%ID%%" => $object->getId());
break;
case "slide":
return array("%%PICTURE%%" => $object->getPicture());
break;
case "category":
$product = Models::getProductObject();
$product->fetchProductByCategoryId($object->getId());
return array("%%ID%%" => $object->getId(), "%%NAME%%" => $object->getName(), "%%CATEGORY_URL%%" => Functions::getDefaultURL() . "product/" . str_replace(" ", "_", $object->getName()), "%%PICTURE%%" => $object->getPicture(), "%%LOGO%%" => $object->getLogo(), "%%DESCRIPTION%%" => $object->getDescription(), "%%COUNT%%" => $product->getCount(), "%%SELECTED%%" => defined("CATEGORY_NAME") && $object->getIdFromName(str_replace("_", " ", CATEGORY_NAME)) == $object->getId() ? "selected" : "");
break;
}
return array();
}
开发者ID:youssefbenhssaien,项目名称:MVC-PHP,代码行数:26,代码来源:index.php
示例2: convertToJSON
/** Convert model to JSON. */
public static function convertToJSON($model, $toString = false)
{
$conversionRules = Models::getConversionRules(get_class($model));
$result = array();
// Keep original simple values:
$objectVars = get_object_vars($model);
foreach ($objectVars as $key => $value) {
if (is_string($value) || is_numeric($value)) {
$result[$key] = $value;
}
}
foreach ($conversionRules as $conversionRule) {
if ($conversionRule instanceof FieldConversionRule) {
$fieldName = $conversionRule->field;
// TODO what if field names in JSON and in model are not the same?
$result[$fieldName] = $conversionRule->toJSON($model->{$fieldName});
} else {
if ($conversionRule instanceof FieldConversionRule) {
// TODO
}
}
}
if ($toString) {
return json_encode($result);
}
return $result;
}
开发者ID:kelvinmbwilo,项目名称:cervical,代码行数:28,代码来源:object.php
示例3: actionModels
/**
* Отображение списка моделей марки.
*/
public function actionModels($mark)
{
if (Yii::app()->request->isAjaxRequest) {
$data = Models::getModels($mark);
$this->renderPartial('models', array('data' => $data, 'mark' => $mark));
Yii::app()->end();
}
}
开发者ID:sergeychibunin,项目名称:glass,代码行数:11,代码来源:MarkController.php
示例4: getReplaceChars
function getReplaceChars($object, $name = "")
{
switch ($name) {
case "product":
$category = Models::getCategoryObject();
return array("%%TITLE%%" => $object->getName(), "%%DESCRIPTION%%" => $object->getDescription(), "%%CATEGORYID%%" => $object->getCategoryId(), "%%CATEGORY%%" => $category->getNameFromId($object->getCategoryId()), "%%PICTURE%%" => $object->getPicture());
break;
case "category":
$product = Models::getProductObject();
$product->fetchProductByCategoryId($object->getId());
return array("%%ID%%" => $object->getId(), "%%NAME%%" => $object->getName(), "%%CATEGORY_URL%%" => Functions::getDefaultURL() . "product/" . str_replace(" ", "_", $object->getName()), "%%PICTURE%%" => $object->getPicture(), "%%DESCRIPTION%%" => $object->getDescription(), "%%COUNT%%" => $product->getCount(), "%%SELECTED%%" => defined("CATEGORY_NAME") && $object->getIdFromName(str_replace("_", " ", CATEGORY_NAME)) == $object->getId() ? "selected" : "");
break;
}
return array();
}
开发者ID:youssefbenhssaien,项目名称:MVC-PHP,代码行数:15,代码来源:product.php
示例5: init
function init($servlet, $request = array())
{
if (isset($_POST["action"]) && strcmp("send", strtolower($_POST["action"])) == 0) {
//$privatekey = "6LfMk_YSAAAAAMIox5-yFggxrvwUmNH-gsiqROQO";
//$resp_captcha = recaptcha_check_answer ($privatekey,$_SERVER["REMOTE_ADDR"],$_POST["recaptcha_challenge_field"],$_POST["recaptcha_response_field"]);
//if(!$resp_captcha->is_valid)$error[]="Le code CAPTCHA ne correspond pas au code affiché sur l'image";
$input = "name";
if (!isset($_POST[$input]) || isset($_POST[$input]) && empty($_POST[$input])) {
$error[] = "(*) Nom doit être remplir";
}
$input = "email";
if (!isset($_POST[$input]) || isset($_POST[$input]) && empty($_POST[$input])) {
$error[] = "(*) Email doit être remplir";
} elseif (isset($_POST[$input]) && !Functions::isEmail($_POST[$input])) {
$error[] = "Format email non valide";
}
$input = "subject";
if (!isset($_POST[$input]) || isset($_POST[$input]) && empty($_POST[$input])) {
$error[] = "(*) Sujet doit être remplir";
}
$input = "message";
if (!isset($_POST[$input]) || isset($_POST[$input]) && empty($_POST[$input])) {
$error[] = "(*) Message doit être remplir";
}
if (!isset($error)) {
$contact = Models::getMessageObject();
// if($contact->add($_POST["name"],$_POST["email"],$_POST["subject"],$_POST["message"])){
if (true) {
$hdrs = array('to' => $_POST["email"], 'from' => $_POST["email"], 'subject' => 'Arenalub contact : ' . $_POST["subject"]);
$values = array("%%NAME%%" => $_POST["name"], "%%SUBJECT%%" => $_POST["subject"], "%%EMAIL%%" => $_POST["email"], "%%MESSAGE%%" => $_POST["message"], "%%DATE%%" => date("d/m/Y à H:i"), "%%FOOTER%%" => Functions::getPublicFile("../servlet/files/mail.footer.html"));
$servlet->html->setCommonArray($values);
$mail = Functions::getMailObject($hdrs);
$message = $servlet->html->getFilteredText(Functions::getPublicFile("../servlet/files/mail.html"));
$mail->setMessage($_POST["message"]);
if (!$mail->send()) {
$error = "Message ajouté avec succée que le mail n'est pas envoyé";
} else {
$error = "no";
}
//unset($_POST);
} else {
$error = "Erreur Technique : votre message ne peut pas être soumettre, veuillez réessayer plus tard :(";
}
}
}
return isset($error) ? $error : false;
}
开发者ID:youssefbenhssaien,项目名称:MVC-PHP,代码行数:47,代码来源:contact1.php
示例6: run
public function run()
{
$response = Router::get();
if (is_array($response)) {
$Class = $response['class'];
$method = $response['method'];
require_once $_SERVER['DOCUMENT_ROOT'] . '/views/' . $Class . '.php';
$Class = sprintf('\\KeyZ\\%s', $Class);
Models::connect();
Session::start();
// Запускаем обработчик запроса и получаем от него данные для отображения
// Выводим данные на экран через шаблонизатор
Views::display($Class::$method($response['params']));
} else {
printf("<b>Error 404:</b> Page not found");
exit;
}
}
开发者ID:kirsantov,项目名称:keyzen,代码行数:18,代码来源:App.php
示例7: getReplaceChars
function getReplaceChars($object, $name = "")
{
switch ($name) {
case "gallery":
$category = Models::getCategoryObject();
return array("%%ID%%" => $object->getId(), "%%TITLE%%" => $object->getName(), "%%DESCRIPTION%%" => nl2br($object->getDescription()), "%%PICTURE%%" => $object->getFirstPicture(), "%%CATEGORYID%%" => $object->getCategoryId(), "%%CATEGORY%%" => $category->getNameFromId($object->getCategoryId()), "%%LIEN%%" => Functions::getDefaultURL() . "portfolio/" . $object->getId() . "_" . str_replace(" ", "_", $object->getName()));
break;
case "gallerydetail":
return array("%%ID%%" => $object->getId(), "%%TITLE%%" => $object->getName(), "%%DESCRIPTION%%" => $object->getDescription(), "%%CATEGORY%%" => $object->getCategoryId());
break;
case "gallerypictures":
return array("%%PICTURE%%" => $object->getPicture());
break;
case "category":
return array("%%ID%%" => $object->getId(), "%%NAME%%" => $object->getName());
break;
}
return array();
}
开发者ID:youssefbenhssaien,项目名称:MVC-PHP,代码行数:19,代码来源:portfolio.php
示例8: init
function init($request = array())
{
if (isset($_POST["action"]) && strcmp("send", strtolower($_POST["action"])) == 0) {
//$privatekey = "6LfMk_YSAAAAAMIox5-yFggxrvwUmNH-gsiqROQO";
//$resp_captcha = recaptcha_check_answer ($privatekey,$_SERVER["REMOTE_ADDR"],$_POST["recaptcha_challenge_field"],$_POST["recaptcha_response_field"]);
//if(!$resp_captcha->is_valid)$error[]="Le code CAPTCHA ne correspond pas au code affiché sur l'image";
$input = "name";
if (!isset($_POST[$input]) || isset($_POST[$input]) && empty($_POST[$input])) {
$error[] = "(*) Nom doit être remplir";
}
$input = "email";
if (!isset($_POST[$input]) || isset($_POST[$input]) && empty($_POST[$input])) {
$error[] = "(*) Email doit être remplir";
} elseif (isset($_POST[$input]) && !Functions::isEmail($_POST[$input])) {
$error[] = "Format email non valide";
}
$input = "subject";
if (!isset($_POST[$input]) || isset($_POST[$input]) && empty($_POST[$input])) {
$error[] = "(*) Sujet doit être remplir";
}
$input = "message";
if (!isset($_POST[$input]) || isset($_POST[$input]) && empty($_POST[$input])) {
$error[] = "(*) Message doit être remplir";
}
if (!isset($error)) {
$contact = Models::getMessageObject();
if ($contact->add($_POST["name"], $_POST["email"], $_POST["subject"], $_POST["message"])) {
$error = "no";
unset($_POST);
} else {
$error = "Erreur Technique : votre message ne peut pas être soumettre, veuillez réessayer plus tard :(";
}
}
}
return isset($error) ? $error : false;
}
开发者ID:youssefbenhssaien,项目名称:MVC-PHP,代码行数:36,代码来源:contact.php
示例9: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer the ID of the model to be loaded
*/
public function loadModel($id)
{
$model = Models::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
开发者ID:sergeychibunin,项目名称:glass,代码行数:13,代码来源:ModelsController.php
示例10: __construct
<?php
class Countries extends AbstractObject
{
public $countries;
public function __construct($array = null, $success = true)
{
parent::__construct($array, $success);
}
}
Models::register('Countries', new ObjectArrayConversionRule('Country', 'countries'));
开发者ID:kelvinmbwilo,项目名称:cervical,代码行数:11,代码来源:Countries.class.php
示例11: __construct
<?php
class TfaApplicationConfiguration extends AbstractObject
{
public $pinTimeToLive;
public $pinAttempts;
public $verificationAttempts;
public $verificationIntervalLength;
public $initiationAttempts;
public $initiationIntervalLength;
public $overallInitiationAttempts;
public $overallInitiationIntervalLength;
public $initiationThrottlingProlongationFactor;
public $initiationThrottlingWaitPeriod;
public function __construct($array = null, $success = true)
{
parent::__construct($array, $success);
}
}
Models::register('TfaApplicationConfiguration');
开发者ID:pwombwa,项目名称:oneapi-php-non-composer,代码行数:20,代码来源:TfaApplicationConfiguration.class.php
示例12: __construct
public $password = '';
//IBSSO Authentication parameter
public $ibssoToken = '';
// is this session authenticated:
public $authenticated = false;
// is user verified:
public $verified = false;
public function __construct($array = null, $success = true)
{
parent::__construct($array, $success);
$this->authenticated = false;
$this->verified = false;
$this->ibssoToken = '';
}
}
function __convert_ib_auth_from_json($object, $json)
{
$data = Utils::getArrayValue($json, 'login', Utils::getArrayValue($json, 'signup', ''));
if (Utils::getArrayValue($data, 'ibAuthCookie', '') !== '') {
$object->username = '';
$object->password = '';
$object->ibssoToken = Utils::getArrayValue($data, 'ibAuthCookie', '');
$object->authenticated = $object->ibssoToken !== '';
$object->verified = Utils::getArrayValue($data, 'verified', 'false') === 'true';
} else {
$object->authenticated = false;
$object->verified = false;
}
}
Models::register('OneApiAuthentication', new ObjectConversionRule('__convert_ib_auth_from_json'));
开发者ID:kelvinmbwilo,项目名称:cervical,代码行数:30,代码来源:OneApiAuthentication.class.php
示例13: __construct
<?php
class Timezones extends AbstractObject
{
public $timezones;
public function __construct($array = null, $success = true)
{
parent::__construct($array, $success);
}
}
Models::register('Timezones', new ObjectArrayConversionRule('Timezone', 'timeZones'));
开发者ID:kelvinmbwilo,项目名称:cervical,代码行数:11,代码来源:Timezones.class.php
示例14: __construct
<?php
class TerminalRoamingExtendedData extends AbstractObject
{
public $destinationAddress;
public $statusId;
public $doneTime;
public $pricePerMessage;
public $mccMnc;
public $servingMsc;
public $censoredServingMsc;
public $gsmErrorCode;
public $originalNetworkName;
public $portedNetworkName;
public $servingHlr;
public $imsi;
public $originalNetworkPrefix;
public $originalCountryPrefix;
public $originalCountryName;
public $isNumberPorted;
public $portedNetworkPrefix;
public $portedCountryPrefix;
public $portedCountryName;
public $numberInRoaming;
public function __construct()
{
parent::__construct();
}
}
Models::register('TerminalRoamingExtendedData');
开发者ID:kelvinmbwilo,项目名称:cervical,代码行数:30,代码来源:TerminalRoamingExtendedData.class.php
示例15: __construct
<?php
class TfaApplication extends AbstractObject
{
public $applicationId;
public $name;
public $enabled;
public $processId;
public $configuration;
public function __construct($array = null, $success = true)
{
parent::__construct($array, $success);
}
}
Models::register('TfaApplication', array(new SubObjectConversionRule('TfaApplicationConfiguration', 'configuration')));
开发者ID:pwombwa,项目名称:oneapi-php-non-composer,代码行数:15,代码来源:TfaApplication.class.php
示例16: __construct
<?php
class IamServiceException extends AbstractObject
{
public $messageId;
public $text;
public $stackTrace;
public function __construct($array = null, $success = true)
{
parent::__construct($array, $success);
}
}
Models::register('IamServiceException');
开发者ID:pwombwa,项目名称:oneapi-php-non-composer,代码行数:13,代码来源:IamServiceException.class.php
示例17: __construct
<?php
class SmsException extends AbstractObject
{
public $messageId;
public $text;
public $variables;
public function __construct($array = null)
{
parent::__construct($array, true);
}
}
function __convert_sms_exception_from_json($object, $json)
{
$exception = Utils::getArrayValue($json, 'requestError.serviceException', Utils::getArrayValue($json, 'requestError.policyException', null));
if ($exception) {
$object->messageId = Utils::getArrayValue($exception, 'messageId', '');
$object->text = Utils::getArrayValue($exception, 'text', '');
$object->variables = Utils::getArrayValue($exception, 'variables', array());
}
}
Models::register('SmsException', new ObjectConversionRule('__convert_sms_exception_from_json'));
开发者ID:kelvinmbwilo,项目名称:cervical,代码行数:22,代码来源:SmsException.class.php
示例18: __construct
<?php
class TfaMessage extends AbstractObject
{
public $applicationId;
public $messageId;
public $senderId;
public $messageText;
public $pinPlaceholder;
public $pinLength;
public $pinType;
public function __construct($array = null, $success = true)
{
parent::__construct($array, $success);
}
}
Models::register('TfaMessage');
开发者ID:pwombwa,项目名称:oneapi-php-non-composer,代码行数:17,代码来源:TfaMessage.class.php
示例19: __construct
<?php
// require_once('SISendMessageResult');
/**
* Send sms response (Social Invite) object.
*/
class SISendSmsResponse extends AbstractObject
{
public $bulkId;
public $deliveryInfoUrl;
public $responses;
public function __construct($array = null, $success = true)
{
parent::__construct($array, $success);
}
}
Models::register('SISendSmsResponse', array(new ObjectArrayConversionRule('SISendMessageResult', 'responses')));
开发者ID:kelvinmbwilo,项目名称:cervical,代码行数:17,代码来源:SISendSmsResponse.class.php
示例20: __construct
<?php
class InboundSmsMessage extends AbstractObject
{
public $dateTime;
public $destinationAddress;
public $messageId;
public $message;
public $resourceURL;
public $senderAddress;
public function __construct($array = null, $success = true)
{
parent::__construct($array, $success);
}
}
Models::register('InboundSmsMessage');
开发者ID:kelvinmbwilo,项目名称:cervical,代码行数:16,代码来源:InboundSmsMessage.class.php
注:本文中的Models类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论