谁一开始就是大神?

PHP 第62页

PHP

@property这样的注释格式,有什么作用,可以一键注释成这种格式吗?[2.0]

littleCherry阅读(112)

/**
 * This is the model class for table "user".
 *
 * @property integer $id
 * @property string $username
 * @property string $mobile
 * @property string $auth_key
 * @property string $password_hash
 * @property string $password_reset_token
 * @property string $email
 * @property integer $status
 * @property integer $role
 * @property string $created_at
 * @property string $updated_at
 * @property string $sex
 */
class User extends \yii\db\ActiveRecord implements IdentityInterface
{

这是符合phpdoc的注释格式,有很多工具可以解析这类注释并且直接生成文档,例如phpDocumentor, doxygen等等。IDE例如eclipse的PDT,InteliJ的IDEA和PHPStorm也能解析这种注释格式,并且根据注释来辅助生成代码提示
如果你使用gii生成代码,比如你用gii生成model,它默认就有这个注释

yii2第三方登录遇到的问题[2.0]

lionJames阅读(108)

发个问题真蛋疼,关闭了又不能删除,写了整整一篇忘记点发布就关了,又得重新写。事情是这样的:我的老大叫我在网站里实现qq第三方登录的功能,用腾讯官方给的SDK,很容易就实现了(这也证明我的流程是没有错的),但是因为项目框架的用yii2,所以,没办法,就上网找咯,Github上官方写的第三方登录扩展是针对facebook、github等外国平台的,在天朝也是没什么luan用的,所以就继续找。

找到两位仁兄写的东西,Yii2中的OAuth扩展及QQ互联登录QQ等第三方登录,后者其实就是模仿前者写的,他自己也作了说明,只是他把QqOAuth这个类放在了不同的地方引用而已,然而并没有什么luan用,因为原作者写的东西本来就有错,连他自己网站的QQ登录也出现那个回调地址有问题的问题,他的QQ登录,发这篇东西原因,是不想你们走我的老路,恳请大神们帮我下,用他们两人写的教程为啥出错?还有我看到本站其实有Qq登录的功能,我想问站长巡洋艦大哥,使用官方SDk,还是自己写好的yii版本呢?能不能分享下怎么实现那个功能?QQ截图20160518104056.png

这里是我的QQ登录的实现 https://github.com/yiichina/yiicms/blob/master/frontend/widgets/QQClient.php
mark,需要时再研究
Mark一下,肯定会要用到的。。
Mark一下,肯定会要用到的
你的问题解决了吗?QQ提示100010,回调错误。我也遇到了这个问题
我现在就纠结这个问题,qq互联回调不让写问号,这b框架自己非要有。网上查很多,但是全 拷贝粘贴的。一个符号不带差的。楼主解决了分享下啊
已集成 第三方登录

yii2实现第三方登录[2.0]

Bravefrog阅读(99)

yii2作为后台如何通过接口写移动端的第三方登录,如qq,微信,求指点

跟纯PHp写思路应该一样吧

控制器问题[2.0]

Newseagull阅读(117)

class HomePageController extends Controller{
	public function actionIndex(){
		return $this->render('index'); 
	}
}

这样访问:
http://127.0.0.1/yii/b/web/index.php?r=home-page
提示:

Not Found (#404)
Page not found.

哪里有错呢?

看下base\controller
url :
http://127.0.0.1/yii/b/web/index.php?r=home-page/index
or
学习了,Camel case controller name not well supported #493,view文件夹也需要是’home-page’。

怎么实现whereid>45anduid=1???[2.0]

Harrydolphin阅读(106)

$data = Chat::find()->where(['>', 'id', 45],'uid'=>1])->asArray()->all(); 要怎么改呢?

还是预处理的更好用
如果先看到底运行的原生sql是什么可以用这样

大家好。。请问在YII2模板中原生PHP语法写法?有没有专门在YII2模板中写原生PHP语法的写法?[2.0]

youthfans阅读(111)

如这段代码。。。

<?php if( ($status['status']) == 1 ): ?>
<span class="wh-collect"><span class="collect"><?php echo '已收藏'; ?></span>(<span id="count">0</span>)</span>
<?endif; ?>
<?php else: ?>
<span class="wh-collect"><span class="collect"><?php echo '收藏'; ?></span>(<span id="count">0</span>)</span>
<?php endif; ?>

转换为YII2中的语法 应该怎么写。。谢谢了。

Yii的模板中 只支持 原生PHP的写法,不需要做什么 转换
直接写,没区别.
提问前没试着把这段代码放到yii里跑一下?
直接写 原生的PHP 就可以了
没有区别,可以直接写
直接写就得了,除了表单,其他没必要用yii写,反倒是脱了裤子放屁 本身浏览器处理的事情 按yii那样写现在还得php引擎处理

yii2分页问题Pagination不显示分页样式[2.0]

richfrog阅读(110)

控制器代码:

<?php

namespace app\controllers;

use Yii;
use yii\web\Controller;
use app\models\Country;
use yii\helpers\ArrayHelper;
use yii\data\Pagination;

class CountryController extends Controller
{
	function actionIndex(){
		$query = Country::find()->where(['status' => 1]);
		$pages = new Pagination(['totalCount' => count($query), 'pageSize' => '1']);
		$models = $query->offset($pages->offset)
		    ->limit($pages->limit)
		    ->all();

		return $this->render('index', [
		     'models' => $models,
		     'pages' => $pages,
		]);
	}
}



?>

view

<?php
use yii\widgets\LinkPager;

foreach ($models as $model) {
    // 在这里显示 $model
    echo 'ID:'.$model->id;
    echo '名称:'.$model->name;
    echo '验证码:'.$model->code;
    echo '<hr/>';

}

?>

 <?php echo  LinkPager::widget(['pagination' => $pages]); ?>

数据库中有11条数据,这里我设置每页显示1条。应该有11页才对。
但是页面只显示foreach中的输出。
却没有看到上下页的分页样式。

对比你的代码,你是怎么用的
没有克隆对象, count()没用对
LinkPager 继承这个类过后,自己再继续重写样式就可以了。

登录

找回密码

注册