我是榆木,我笨,但是大哥能不能看在我才上班1个月的份上,不要生我气了。 问题已经解决了 就是大哥说的这个方法。很管用,我其他几个地方对比了一下,也有相似的错误。正在修改中。 感谢。
我在控制器测试了,返回一个数值是可以的,就是通过调用服务层的时候有问题。
bolck 层调用common配置:** $this->_service = Yii::$service->sitesmanage; **
common配置在 ** fecshop/common/config/fecshop_local_services/Sitesmanage.php **
内容如下:
return [
'sitesmanage' => [
'class' => 'appadmin\local\local_services\Sitesmanage',
],
];
然后对应的service层内容大致如下:
class Sitesmanage extends Service
{
//站点表
protected $_sitesModelName = '\appadmin\local\local_models\mysqldb\Shopconfig';
protected $_sitesModel;
//订单表
protected $_orderModelName = '\appadmin\local\local_models\mysqldb\order\Orderinfo';
protected $_orderModel;
public function __construct(){
list($this->_sitesModelName,$this->_sitesModel) = \Yii::mapGet($this->_sitesModelName);
list($this->_orderModelName,$this->_orderModel) = \Yii::mapGet($this->_orderModelName);
}
}
最后的数据库**fecshop/appadmin/local/local_models/mysqldb/order/OrderInfo.php**
内容:
use yii\db\ActiveRecord;
class OrderInfo extends ActiveRecord
{
public static function tableName()
{
return "sales_flat_order";
}
}
报错信息则如下:
看过了 我尝试改过。但是报更多的错了,报的是代码有问题,但是我在本地改过之后运行却不影响。。有点头大,服务器好像linux的,大小写比较严谨,我再看看吧 谢了。等我测试成功再来回帖。
因为我是模仿的其他的写法写的, 我以为路由方法就是这样。
这个配置的时候 model中Xxx.php首字母大写,在服务层调用时,'\appadmin\local\local_models\mysqldb\Xxx'也应该这样吗?因为我是模仿的其他文件的,而且写出来在本地也能访问。
文件存在,而且也是大写,我是用的win, 环境都搭在win上的,如果要换还得装虚拟机,重新搭建环境。现在就想弄个测试版出来先看看。
感觉是某个配置文件的问题,因为每个都是报的同样的错误,只是文件名不一样而已。
我修改了fecshop/common/config/main-local.php 中的内容
return [
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=fecshop',
'username' => '账号',//chenjq_db
'password' => '密码',
'charset' => 'utf8',
],
'mongodb' => [
'class' => 'yii\mongodb\Connection',
// 有账户的配置
//'dsn' => 'mongodb://username:password@localhost:27017/datebase',
// 无账户的配置
'dsn' => 'mongodb://IP/连接名',
],
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@common/mail',
// send all mails to a file by default. You have to set
// 'useFileTransport' to false and configure a transport
// for the mailer to send real emails.
'useFileTransport' => true,
],
'redis' => [
'class' => 'yii\redis\Connection',
'hostname' => 'IP',
'port' => 6379,
//'password' => '密码',
],
],
];
标题:
Invalid Configuration – yii\base\InvalidConfigException
The directory is not writable by the Web process: /var/html/www/fecshop/appadmin/web/assets
1. in /var/html/www/fecshop/vendor/yiisoft/yii2/web/AssetManager.php at line 215
206207208209210211212213214215216217218219220221222223224 * @throws InvalidConfigException if [[basePath]] is invalid
*/
public function init()
{
parent::init();
$this->basePath = Yii::getAlias($this->basePath);
if (!is_dir($this->basePath)) {
throw new InvalidConfigException("The directory does not exist: {$this->basePath}");
} elseif (!is_writable($this->basePath)) {
throw new InvalidConfigException("The directory is not writable by the Web process: {$this->basePath}");
} else {
$this->basePath = realpath($this->basePath);
}
$this->baseUrl = rtrim(Yii::getAlias($this->baseUrl), '/');
}
/**
* Returns the named asset bundle.
*
2. in /var/html/www/fecshop/vendor/yiisoft/yii2/base/Object.php at line 107 – yii\web\AssetManager::init()
3. yii\base\Object::__construct(['forceCopy' => false])
4. in /var/html/www/fecshop/vendor/yiisoft/yii2/di/Container.php at line 381 – ReflectionClass::newInstanceArgs([['forceCopy' => false]])
5. in /var/html/www/fecshop/vendor/yiisoft/yii2/di/Container.php at line 156 – yii\di\Container::build('yii\web\AssetManager', [], ['forceCopy' => false])
6. in /var/html/www/fecshop/vendor/yiisoft/yii2/BaseYii.php at line 348 – yii\di\Container::get('yii\web\AssetManager', [], ['forceCopy' => false])
7. in /var/html/www/fecshop/vendor/yiisoft/yii2/di/ServiceLocator.php at line 135 – yii\BaseYii::createObject(['forceCopy' => false, 'class' => 'yii\web\AssetManager'])
8. in /var/html/www/fecshop/vendor/yiisoft/yii2/base/Application.php at line 605 – yii\di\ServiceLocator::get('assetManager')
9. in /var/html/www/fecshop/vendor/yiisoft/yii2/web/View.php at line 225 – yii\base\Application::getAssetManager()
10. in /var/html/www/fecshop/vendor/yiisoft/yii2/web/View.php at line 285 – yii\web\View::getAssetManager()
11. in /var/html/www/fecshop/vendor/yiisoft/yii2/web/AssetBundle.php at line 125 – yii\web\View::registerAssetBundle('yii\web\JqueryAsset')
12. in /var/html/www/fecshop/vendor/yiisoft/yii2/web/View.php at line 443 – yii\web\AssetBundle::register(yii\web\View)
13. in /var/html/www/fecshop/vendor/fancyecommerce/fec_admin/views/login/index.php at line 55 – yii\web\View::registerJs(' $(document).ready(function(...', 5)
最下方报错:
r\nregisterJs($this->blocks['js_end'],\\yii\\web\\View::POS_LOAD); ?>\r\n14. in /var/html/www/fecshop/vendor/yiisoft/yii2/base/View.php at line 330 – require('/var/html/www/fecshop/vendor/fan...')\r\n15. in /var/html/www/fecshop/vendor/yiisoft/yii2/base/View.php at line 250 – yii\\base\\View::renderPhpFile('/var/html/www/fecshop/vendor/fan...', ['error' => ''])\r\n16. in /var/html/www/fecshop/vendor/yiisoft/yii2/base/View.php at line 152 – yii\\base\\View::renderFile('/var/html/www/fecshop/vendor/fan...', ['error' => ''], fecadmin\\controllers\\LoginController)\r\n17. in /var/html/www/fecshop/vendor/yiisoft/yii2/base/Controller.php at line 381 – yii\\base\\View::render('index', ['error' => ''], fecadmin\\controllers\\LoginController)\r\n18. in /var/html/www/fecshop/vendor/fancyecommerce/fec_admin/controllers/LoginController.php at line 138 – yii\\base\\Controller::render('index', ['error' => ''])\r\n132133134135136137138139140141142143144 return $this->redirect(\"/\")->send();\r\n }else{\r\n $errors = CModel::getErrorStr($AdminUserLogin->errors);\r\n }\r\n }\r\n $this->layout = \"login.php\";\t\r\n return $this->render('index',['error' => $errors]);\r\n }\r\n \r\n \r\n \r\n \r\n \r\n19. fecadmin\\controllers\\LoginController::actionIndex()\r\n20. in /var/html/www/fecshop/vendor/yiisoft/yii2/base/InlineAction.php at line 57 – call_user_func_array([fecadmin\\controllers\\LoginController, 'actionIndex'], [])\r\n21. in /var/html/www/fecshop/vendor/yiisoft/yii2/base/Controller.php at line 156 – yii\\base\\InlineAction::runWithParams([])\r\n22. in /var/html/www/fecshop/vendor/yiisoft/yii2/base/Module.php at line 523 – yii\\base\\Controller::runAction('index', [])\r\n23. in /var/html/www/fecshop/vendor/yiisoft/yii2/web/Application.php at line 102 – yii\\base\\Module::runAction('fecadmin/login/index', [])\r\n24. in /var/html/www/fecshop/vendor/yiisoft/yii2/base/Application.php at line 380 – yii\\web\\Application::handleRequest(yii\\web\\Request)\r\n25. in /var/html/www/fecshop/appadmin/web/index.php at line 62 – yii\\base\\Application::run()\r\n56575859606162 * 使用方法:Yii::$service->cms->article;\r\n * 上面的例子就是获取cms服务的子服务article。\r\n */\r\nnew fecshop\\services\\Application($config['services']);\r\nunset($config['services']);\r\n$application = new yii\\web\\Application($config);\r\n$application->run();\r\n\r\n请就火力支援。。。。在线等。","name":"Topic[content]","path":"/assets/ed623a17/lib/"}); jQuery('#topic-tags').select2({"width":"100%"}); jQuery('#w0').yiiActiveForm([{"id":"topic-title","name":"title","container":".field-topic-title","input":"#topic-title","validate":function (attribute, value, messages, deferred, $form) {yii.validation.required(value, messages, {"message":"标题不能为空。"});yii.validation.string(value, messages, {"message":"标题必须是一条字符串。","min":2,"tooShort":"标题应该包含至少2个字符。","max":250,"tooLong":"标题只能包含至多250个字符。","skipOnEmpty":1});}},{"id":"topic-post_meta_id","name":"post_meta_id","container":".field-topic-post_meta_id","input":"#topic-post_meta_id","validate":function (attribute, value, messages, deferred, $form) {yii.validation.required(value, messages, {"message":"分类不能为空。"});yii.validation.number(value, messages, {"pattern":/^\s*[+-]?\d+\s*$/,"message":"分类必须是整数。","skipOnEmpty":1});}},{"id":"topic-content","name":"content","container":".field-topic-content","input":"#topic-content","validate":function (attribute, value, messages, deferred, $form) {yii.validation.required(value, messages, {"message":"内容不能为空。"});yii.validation.string(value, messages, {"message":"内容必须是一条字符串。","min":2,"tooShort":"内容应该包含至少2个字符。","skipOnEmpty":1});}}], []); });
解决了 尝试了多重办法之后,最后无心的一个技能解决了。
$query=$this->_spreadModel->find();
$query->select(array('*','(select msg from '.$this->_msgModel->tableName().' as message where msg_id=message.id) as user_msg','(select spread_type from '.$this->_msgModel->tableName().' as message where msg_id=message.id) as spread_type'));
就是往数组总再次添加一个命令用逗号隔开