在模板助手中,我从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
我正在使用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) 我的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) 我正在使用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) 我是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编辑器中为以下类提供自动完成功能:
<?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
我有一个表格的页面.以下哪种方法最好用于检查表单是否已提交?它们有何不同?
方法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) 我已经检查了很多,但我无法理解它.
我需要将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 ×7
mysql ×3
cakephp ×2
autocomplete ×1
caching ×1
cakephp-2.0 ×1
codeigniter ×1
editor ×1
eloquent ×1
form-submit ×1
forms ×1
get ×1
hybridauth ×1
iron-router ×1
laravel ×1
laravel-4 ×1
meteor ×1
pivot ×1
post ×1
sql-parser ×1