对于Phalcon的0.5.0版本,如何安装phalcon-devtools以便我可以通过命令shell使用它们?
我已经在Mac中安装了Thrift。
从终端看来,thrift已成功安装,但是当我尝试运行thrift命令时,得到以下信息
Thrift: command not found
Run Code Online (Sandbox Code Playgroud)
我从终端使用了whereis命令来找到节俭的位置,但找不到它。
有什么建议么?
安装节俭节俭0.9.0后的终端输出
Building C++ Library ......... : yes
Building C (GLib) Library .... : no
Building Java Library ........ : yes
Building C# Library .......... : no
Building Python Library ...... : yes
Building Ruby Library ........ : yes
Building Haskell Library ..... : no
Building Perl Library ........ : yes
Building PHP Library ......... : yes
Building Erlang Library ...... : no
Building Go Library .......... : no
Building D Library ........... …Run Code Online (Sandbox Code Playgroud) 我想在文本文件中记录下载
有人来到我的网站并下载了一些东西,它会在文本文件中添加一个新行(如果尚未增加或增加当前文件).
我试过了
$filename = 'a.txt';
$lines = file($filename);
$linea = array();
foreach ($lines as $line)
{
$linea[] = explode("|",$line);
}
$linea[0][1] ++;
$a = $linea[0][0] . "|" . $linea[0][1];
file_put_contents($filename, $a);
Run Code Online (Sandbox Code Playgroud)
但它总是增加1以上
文本文件格式是
name|download_count
Run Code Online (Sandbox Code Playgroud) 如果我尝试使用beforeCreate()方法中定义的date_created字段保存模型,则不会保存它:
class TestEntity extends Phalcon\Mvc\Model
{
public function beforeCreate()
{
$this->date_created = date('Y-m-d H:i:s');
}
/**
* Returns source table name
* @return string
*/
public function getSource()
{
return 'test_entity';
}
}
Run Code Online (Sandbox Code Playgroud)
控制器动作上下文
$test = new TestEntity();
$test->name = 'test';
var_dump($contact->save()); // gives false
var_dump($contact->getMessages()); // says date_created is not defined
Run Code Online (Sandbox Code Playgroud) 我需要一些在Regex上比我更好的人的帮助:)
我试图使用.NET(C#)在字符串中查找特定标记的值
我拥有的字符串有这样的标记 {token:one}
我的功能如下:
public static ArrayList GetMatches(string szInput)
{
// Example string
// Lorem ipsum {token:me} lala this {token:other} other stuff
ArrayList aResults = new ArrayList();
string szPattern = @"(\{token:(*)\})";
foreach (Match match in Regex.Matches(szInput, szPattern))
{
aResults.Add(match.Value);
}
// It should contain me and other
return aResults;
}
Run Code Online (Sandbox Code Playgroud)
任何指针都不仅仅是值得赞赏的.
我正在使用PHP 5.3,phalcon 0.5.0跟踪OS X 10.8上的教程.我有一个tutorial在我的apache的web根目录中调用的文件夹.当我使用代码时:
echo Phalcon\Tag::linkTo("signup", "Sign Up Here!");
Run Code Online (Sandbox Code Playgroud)
在输出html我得到
localhost/signup
Run Code Online (Sandbox Code Playgroud)
代替
localhost/tutorial/signup
Run Code Online (Sandbox Code Playgroud)
我还在我的.htacess文件中输入了RewriteBase/tutorial /,但仍然遇到同样的问题.我在0.4的phalcon和0.5中都有同样的问题
这里,在docs中,写了关于如何创建路由的文章:http: //docs.phalconphp.com/en/latest/reference/routing.html
但我无法找到我如何在应用程序中注入它们.我需要做什么,让我的应用程序使用定义的路由?
我应该注入路由器(或如何?)
我找到了以下示例:
$robots = Robots::find(array("limit" => 100));
Run Code Online (Sandbox Code Playgroud)
是否可以为限制"从"和"偏移"定义两个值?在Zend Framework中,有可能使用Db适配器功能,如下所示:
$db->select()->limit($from, $offset)
Run Code Online (Sandbox Code Playgroud) 我是iOS的初学者.我创建了一个UIScrollview带有5个图像并根据方向设置其宽度,高度和大小的变化.添加所有5个图像后,滚动视图子视图计数为5.但是当开始拖动时,计数增加到7.我不知道添加空白视图的位置.
-(void)addImageWithName:(NSString*)imageString atPosition:(int)position {
UIImage *image = [UIImage imageWithContentsOfFile:imageString];
imageView = [[UIImageView alloc] initWithImage:image];
// imageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
imageView.frame = CGRectMake(position*scrollview.frame.size.width*2, 0, scrollview.frame.size.width *2,scrollview.frame.size.height );
imageView.tag = 1000 + position +1;
[scrollview addSubview:imageView];
}
-(void)imageLoad:(NSInteger)startImage
{
int Index = -1;
for (UIImageView *subview in scrollview.subviews)
{
[subview removeFromSuperview];
}
for (int i = startImage; i < startImage+5; i++) {
Index++;
fullPath = [dataPath stringByAppendingString:[NSString stringWithFormat:@"/image%d.jpg",i]];
[self addImageWithName:fullPath atPosition:Index];
scrollview.contentSize = CGSizeMake(i*scrollview.frame.size.width, 0);
}
}
Run Code Online (Sandbox Code Playgroud)