小编Gun*_*uns的帖子

流星铁路由器从模板助手中的参数获取当前路径

在模板助手中,我从Iron.Router(iron:router)获取当前路径,如下所示:

Router.current().route.path()
Run Code Online (Sandbox Code Playgroud)

这工作正常,除非路径路径确实包含参数(例如/client/:_id/edit).在那种情况下,path()函数返回null.

当路由包含参数时,如何获取模板助手中的当前路径?

我正在使用Meteor 1.0和iron:router1.0.1

meteor iron-router

14
推荐指数
2
解决办法
2万
查看次数

HybirdAuth用户个人资料请求失败

我正在使用HybridAuth2和CakePHP,我的控制器功能是

public function loginwith($provider) {
        //        $this->autoRender = false;
        require_once( WWW_ROOT . 'hybridauth/Hybrid/Auth.php' );

        $hybridauth_config = array(
            "base_url" => 'http://' . $_SERVER['HTTP_HOST'] . $this->base . "/hybridauth/", // set hybridauth path
            "providers" => array(
                "Google" => array(
                    "enabled" => true,
                    "keys" => array("id" => "clientID", "secret" => "clientSecret")
                )
            )
        );

        try {
            // create an instance for Hybridauth with the configuration file path as parameter
            $hybridauth = new Hybrid_Auth($hybridauth_config);

            // try to authenticate the selected $provider
            $adapter = $hybridauth->authenticate($provider);

            // …
Run Code Online (Sandbox Code Playgroud)

php cakephp hybridauthprovider hybridauth

6
推荐指数
1
解决办法
3459
查看次数

CakePHP Cache :: clear不起作用

我的bootstrap.php文件中有一个缓存配置

Cache::config('long', array(
        'engine'     => 'File',
        'duration'   => '+1 week',
        'probability'=> 100,
        'mask'       => 0666,
        'path'       => CACHE . 'long' . DS,
    ));
Run Code Online (Sandbox Code Playgroud)

我正在尝试在编辑设置时清除缓存.以下是我的admin_edit函数

public function admin_edit($id = null) {
        if (!$this->Setting->exists($id)) {
            throw new NotFoundException(__('Invalid setting'));
        }
        if ($this->request->is('post') || $this->request->is('put')) {
            if ($this->Setting->save($this->request->data)) {
                $this->Session->setFlash(__('The setting has been saved'));
                $this->redirect(array('action'=> 'index'));
                Cache::clear(false,'long');
                Cache::gc();
            }else {
                $this->Session->setFlash(__('The setting could not be saved. Please, try again.'));
            }
        }else {
            $options = array('conditions' => array('Setting.' . $this->Setting->primaryKey=> $id));
            $this->request->data = $this->Setting->find('first', …
Run Code Online (Sandbox Code Playgroud)

php caching cakephp cakephp-2.0

5
推荐指数
1
解决办法
1万
查看次数

MySQL错误 - 命令不同步; 你现在不能运行这个命令

我正在使用MySQL和PHP,Codeigniter.我有一个问题,由bluefeet在这里的帖子回答

我为bluefeet创建了第二个解决方案的存储过程.然而,它工作得很完美,而在生产环境中调用该过程时,所有其他用户都会收到错误

命令不同步; 你现在不能运行这个命令

不知道我怎么能克服这个错误.我还尝试在调用过程后关闭连接,但是,在关闭连接之前,将执行来自其他用户的查询.解决这个问题的任何解决办法?

下面是我使用的存储过程

DROP PROCEDURE IF EXISTS mailbox.circle_pending_p;
CREATE PROCEDURE mailbox.`circle_pending_p`()
BEGIN
SET @sql = NULL;
SELECT
  GROUP_CONCAT(DISTINCT
    CONCAT(
      'sum(CASE WHEN maildate = ''',
      date_format(mailtime, '%e-%b'),
      ''' THEN 1 else 0 END) AS `',
      date_format(mailtime, '%e-%b'), '`'
    )
  ) INTO @sql
FROM circle_pending_temp
WHERE mailtime >= (select date_sub(max(mailtime), interval 8 DAY)
                   from circle_pending_temp);

SET @sql 
  = CONCAT('SELECT coalesce(email_Circle, ''Grand Total'') Circle,
              max(`< 9 days`) `< 9 days`, ', @sql, ' ,
              count(*) GrandTotal
            from
            ( …
Run Code Online (Sandbox Code Playgroud)

php mysql pivot stored-procedures codeigniter

3
推荐指数
1
解决办法
3万
查看次数

从控制器访问模型 - Laravel 4

我是Laravel的新手.如果这个问题听起来很奇怪,请原谅.

我有一个模特

class Config extends Eloquent {

    public static $table = 'configs';

}
Run Code Online (Sandbox Code Playgroud)

并且控制器变为

class UserController extends BaseController {

    Public function getIndex ()
    {
        $config_items = Config::all ();
        var_dump ( $config_items );
        return View::make ( 'user.userindex' )
                        -> with ( 'title', 'User Page' );
    }

}
Run Code Online (Sandbox Code Playgroud)

但是当我尝试访问Config模型时,我收到错误:

Symfony\Component\Debug\Exception\FatalErrorException调用未定义的方法Illuminate\Config\Repository :: all()

错误信息

请帮忙!

我知道这个问题可以帮助很多像我和我的同事一样的Laravel 4新手,所以请帮忙!

php mysql laravel eloquent laravel-4

3
推荐指数
2
解决办法
8770
查看次数

如何为魔术方法__call获得自动完成功能-PHP编辑器

我们可以在PHP编辑器中为以下类提供自动完成功能:

<?php

/**
 * Class Controller
 * @property foo foo
*/
class Controller {
   public function bar() {
      $this->foo-> // autocomplete here
   }
}

class foo() {
}
Run Code Online (Sandbox Code Playgroud)

但是如果我想为魔术方法自动完成,__call那怎么可能

下面的例子:

<?php

Class Controller {

   public function __call($function, $arguments) {
      if($function == 'foo') {
         // some logic here
      }
   }
}

Class Home extends Controller {
   public function somefunction() {
      $this-> // should have an autocomplete of foo
   }
}
Run Code Online (Sandbox Code Playgroud)

不知道如何在PHP编辑器中配置自动完成功能

如果有某些特定的东西,我会使用PHP-Storm

php code-formatting autocomplete editor

3
推荐指数
1
解决办法
1357
查看次数

检查用户是否提交表单的正确方法

我有一个表格的页面.以下哪种方法最好用于检查表单是否已提交?它们有何不同?

方法1:

if($_SERVER['REQUEST_METHOD'] == 'POST'){
    //some code
}
Run Code Online (Sandbox Code Playgroud)

方法2:

if(isset($_POST['submit'])){
    //some code
}
Run Code Online (Sandbox Code Playgroud)

方法3(显然,如果我将submitted=true提交添加到查询字符串):

if($_GET['submitted'] == true){
    //some code
}
Run Code Online (Sandbox Code Playgroud)

php forms post get form-submit

1
推荐指数
1
解决办法
390
查看次数

拆分字符串;

我已经检查了很多,但我无法理解它.

我需要将sql转储拆分为查询.

我需要什么基本上采取这样的字符串:

DROP TABLE IF EXISTS `GDN_Activity`;

CREATE TABLE `GDN_Activity` (
  `ActivityID` int(11) NOT NULL AUTO_INCREMENT,
  `ActivityTypeID` int(11) NOT NULL,
  `NotifyUserID` int(11) NOT NULL DEFAULT '0',
  `ActivityUserID` int(11) DEFAULT NULL,
  `RegardingUserID` int(11) DEFAULT NULL,
  `Photo` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `HeadlineFormat` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `Story` text COLLATE utf8_unicode_ci,
  `Format` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
  `Route` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `RecordType` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
  `RecordID` int(11) DEFAULT NULL,
  `InsertUserID` int(11) DEFAULT NULL,
  `DateInserted` datetime NOT …
Run Code Online (Sandbox Code Playgroud)

php mysql sql-parser

0
推荐指数
1
解决办法
129
查看次数