升级wordpress的时候遇到:Briefly unavailable for scheduled maintenance. Check back in a minute.
其实解决方法很简单,到wordpress的根目录下。删除 .maintenance 文件即可。
如果用sql语句来写group by 再count,这样的sql太容易 了。但由于现在都是在用框架,反而这类sql变得难写了。最近在折腾一个用TP 3框架写的代码,原来代码里写的是:
PHP代码
- $count = D('Album')->table(T('albums AS a'))
- ->join(T('union AS u') . ' ON u.id=a.union_id')
- ->join(T('company AS c') . ' ON c.id=a.store_id')
- ->join(T('photo AS p') . ' ON a.id=p.parent_id')
- ->field('a.*,u.name AS union_name,c.name as store_name')
-
- ->where($where)
- ->group('a.id')
- ->count();
看起来好象没有问题,但事实上。出来的结果却并不是你想要的,这个count并不是你要的count,而是每个组的条数。当然你也可以用select()来查出数据,再count($count)一下,但如果数据量过大。这样会崩溃 的。
最终用这样的方法解决了:
PHP代码
- $numsQuery = D('Album')->table(T('albums AS a'))
- ->join(T('union AS u') . ' ON u.id=a.union_id')
- ->join(T('company AS c') . ' ON c.id=a.store_id')
- ->join(T('photo AS p') . ' ON a.id=p.parent_id')
- ->field('a.*,u.name AS union_name,c.name as store_name')
-
- ->where($where)
- ->group('a.id')
- ->buildSql();
- $nums = D()->table("{$numsQuery} as t")->count();
算是曲线求国吧。
其实很多人在问这种问题了,但更多的人建议是直接写sql。我这种是不写sql的啦 ~
看到这个,应该明白了吧
delete from sablog_comments where visible =0 and content REGEXP '^[0-9a-zA-Z]{6} '
定期执行一下吧。NND
PHP使用者大多对composer是又爱又恨,爱的是composer require后,很多类库不用去下载了,恨的是网速卡成翔,虽然国内有很多道友做了镜象,但对于bower库这些都还是整体更新。
那么,如何只利用composer的基本功能来为自己服务呢?composer的官网有介绍,只要在composer.json中加入几行代码就行了。。
JavaScript代码
- "repositories":[
- {
- "type":"git",
- "url":"/var/www/gouki/test/"
- },
- ]
上面的代码中/var/www/gouki/test,是我的一个git库。也是按照composer的标准来建的。里面只有一个composer.json文件:
JavaScript代码
- {
- "name":"gouki/test",
- "description":"test",
- "authors":[
- {
- "name":"gouki",
- "email":"xxxx@qq.com"
- }
- ],
- "minimum-stability":"dev",
- "require":{},
- "autoload":{
- "psr-4":{
- "gouki\\test\\":"src/"
- }
- },
- "extra":{
- "branch-alias":{
- "dev-master":"1.0.x-dev"
- }
- }
- }
src目录下的代码中使用的namespace就是gouki\test,然后在原项目的composer.json中再加入:
JavaScript代码
- "require":{
- "gouki/test":"dev-master"
- },
最后,运行一下composer update,你会看到项目的根目录下多了vendor目录,同时,vendor目录下也会多一个gouki/test的目录,至此项目引入成功,如果还不放心,那就看一下:vendor/composer/autoload_psr4.php中有没有gouki/test。
之所以这么做,就是因为前文所说的速度,当然也有小团队的成本。比如写个类,就可以直接composer进行加载了。
问题就这么来了,如果放到线上去,那上面的
XML/HTML代码
- "repositories":[
- {
- "type":"git",
- "url":"/var/www/gouki/test/"
- },
- ]
- 需要改为:
- "repositories":[
- {
- "type":"git",
- "url":"http://xxxx.xxx.xxx/git"
- },
- ]
如果该git是public的,则不需要任何处理,如果git是需要登录的,则需要在项目的根目录下(和composer.json平级的目录)增加一个auth.json,里面也就两三行代码
JavaScript代码
- {
- "http-basic":{
- "http://xxxx.xxx.xxx/git":{
- "username":"",
- "password":""
- }
- }
- }
当然如果你是ssh免登陆的git则另计。至此一个小小的自建composer源就已经完成。
标题的内容也是手贱导致的,本来composer不self-update也不会出现这个问题,这不,一升到最新的composer就出问题了
1、由于我们为了追求速度,大部分都是用的国内的源,这些源往往都不是https的,这回好了,出错了。
XML/HTML代码
- Your configuration does not allow connection to http://packagist.phpcomposer.com. See https://getcomposer.org/doc/06-config.md#secure-http for details.
- http://packagist.phpcomposer.com could not be fully loaded, package information was loaded from the local cache and may be out of date
OK,打开https://getcomposer.org/doc/06-config.md#secure-http查看了一下,在composer.json和~/.composer/config.json中的config节点下,增加:"secure-http":false
2、composer update的时候报:
XML/HTML代码
- Installation failed, reverting ./composer.json to its original content.
OK,现在可以用composer diag来检查 一下了,结果 发现:
XML/HTML代码
- composer diag
- Checking composer.json: FAIL
- No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.
- require.yiisoft/yii2 : unbound version constraints (*) should be avoided
- Checking platform settings: OK
- Checking git settings: OK
- Checking http connectivity to packagist: OK
- Checking https connectivity to packagist: OK
- Checking github.com oauth access: OK
- Checking disk free space: OK
- Checking pubkeys:
- Tags Public Key Fingerprint: ???? 已隐藏
- Dev Public Key Fingerprint: ????? 已隐藏
- OK
- Checking composer version: FAIL
- You are not running the latest stable version, run `composer self-update` to update (e8b1a5f35772e39ca21ab855a278bd84a0a534b2 => 1.0.0-beta2)
居然显示 ,composer中一定要有license节点,require的也需要带 版本号了。于是一一加上,然后接着composer update
3、出现如标题一般的错误
处理方法:一般出现这种错误 ,大部分情况下是fxp插件需要更新了,执行composer global require fxp/composer-asset-plugin --prefer-dist,
XML/HTML代码
- Changed current directory to /Users/gouki/.composer
- Using version ^1.1 for fxp/composer-asset-plugin
- ./composer.json has been updated
- Loading composer repositories with package information
- Updating dependencies (including require-dev)
- - Removing fxp/composer-asset-plugin (v1.1.1)
- - Installing fxp/composer-asset-plugin (v1.1.2)
- Downloading: 100%
-
- Writing lock file
- Generating autoload files
更新完后,再composer udpate就OK了!
当然如果还有问题,你应该查看官网的issue,比如:https://github.com/francoispluchino/composer-asset-plugin/issues/191,刚开始的时候确实是BUG,后面更新了就好了。哈哈