谁能告诉我,我有几个模式:一种产品有很多→ 属性,在属性有许多→ 特点 ,我可以这样做:
return Item::find()->where(['code' => $code])->with('properties')->asArray()->one();
Run Code Online (Sandbox Code Playgroud)
结果:
{
title: "????? ???????? ????????? 150 ? ???????",
new: "0",
hit: "0",
recommend: "0",
properties: [
{
//lallala
},
{
//lallala
},
]
}
Run Code Online (Sandbox Code Playgroud)
但我想在每个属性中嵌套行(特征)我怎么能做那么优雅的方式?
我刚收到这个错误:
Fatal error: Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with message 'Module (ZfcUserOverride) could not be initialized.' in F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php:189 Stack trace:
#0 F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php(163): Zend\ModuleManager\ModuleManager->loadModuleByName(Object(Zend\ModuleManager\ModuleEvent))
#1 F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php(90): Zend\ModuleManager\ModuleManager->loadModule('ZfcUserOverride')
#2 [internal function]: Zend\ModuleManager\ModuleManager->onLoadModules(Object(Zend\ModuleManager\ModuleEvent))
#3 F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(468): call_user_func(Array, Object(Zend\ModuleManager\ModuleEvent))
#4 F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(207): Zend\EventManager\EventManager->triggerListeners('loadModules', Object(Zend\ModuleManager\ModuleEvent), NULL)
#5 F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php(109): Zend\EventManager\EventManager->trigger('loadModules', Object(Zend\ModuleManager\ModuleManager), Object(Zend\ModuleManager\ModuleEvent))
#6 F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\Mvc\Application.php(252): Zend\ModuleManager\ModuleManager->loadModules()
#7 F:\Server\domains\zf2-skeleton\public\index.php(17): Zend\Mvc\Application::init(Array)
#8 {main} thrown in F:\Server\domains\zf2-skeleton\vendor\zendframework\zendframework\library\Zend\ModuleManager\ModuleManager.php on line 189
Run Code Online (Sandbox Code Playgroud)
所有,我从这个错误得到的是理解问题在ZfcUserOverride模块中.但这里有"加密"的其他有用信息:)?
我有一个函数计算两个坐标之间的距离,如下所示:
function distance(origin, destination) {
//Utilities.sleep(Math.random() * 60000);
destination = destination + "";
if (destination.split(",").length == 2) {
var directions = Maps.newDirectionFinder()
.setOrigin(origin)
.setDestination(destination)
.getDirections();
if (directions.routes.length > 0) {
return directions.routes[0].legs[0].distance.value / 1000;
}
return "-";
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
它在电子表格中使用如下:
=distance("83.342353,23.23353", V2)
Run Code Online (Sandbox Code Playgroud)
该函数运行正常但达到了url调用的速率限制,因为我的电子表格有超过200行.错误消息是:
服务在短时间内调用了太多次:urlfetch保护主机rateMax.在两次通话之间尝试Utilities.sleep(1000).(第5行)
修复建议是Utitlies.sleep()在代码中添加一个.我应该把它放在哪里?
我创建了一个自定义验证功能.现在我想在该功能中验证电子邮件,我该怎么做?以下是我的代码:
public function rules()
{
return [
['email', 'filter', 'filter' => 'trim'],
['email', 'required'],
['email', 'validateEmail'],
];
}
public function validateEmail($attribute, $params) {
if(ctype_digit($this->email)){
if(strlen($this->email)!=10)
$this->addError($attribute,'Phone number should be of 10 digits');
else{// Email validation using emailvalidator.}
}
}
Run Code Online (Sandbox Code Playgroud) 在Ubuntu的文本字段和其他文本编辑器中,按下鼠标中键会将当前突出显示的文本复制到当前指针位置.这在Visual Studio Code v1.0.0中不起作用.我该如何启用它?