Yii Relational record with condition from other table

I have a relational record similar to the following: There are users (table users) with ids There are categories (table categories) with id, name There are articles (table articles) with id, body, category_id Then there is a table read_articles with article_id, user_id So a user can see a list of all articles in a category. They can click on an article and it will add an entry (user_id

Yii与其他表的条件关系记录

我有一个类似于以下的关系记录: 有用户(表用户)与ID 有id,名称的类别(表格类别) 有id,body,category_id的文章(表格文章) 然后是一个带有article_id,user_id的read_articles表 因此用户可以看到一个类别中所有文章的列表。 他们可以点击一篇文章,它会在read_articles表中添加一个条目(user_id,article_id)。 我希望能够使用Yii的ActiveRecord获取当前用户尚未读取的给定类别中的所有文章并显示这些文

I can't set cron job

I've tried to set a cron job in "crontab -e": * * * * * /usr/bin/php /home/vagrant/Code/xxx/testCron.php testCron.php file creates another file, it contains only this: <?php $f = fopen('cron-' . date('H-i-s') . '.txt', 'w+'); fwrite($f, 'asdf'); fclose($f); But the file cron-....txt doesn't appear. Were can be a problem? I did/checked this: Cron is working. I checke

我无法设置cron作业

我试图在“crontab -e”中设置一个cron作业: * * * * * /usr/bin/php /home/vagrant/Code/xxx/testCron.php testCron.php文件创建另一个文件,它只包含这个: <?php $f = fopen('cron-' . date('H-i-s') . '.txt', 'w+'); fwrite($f, 'asdf'); fclose($f); 但文件cron -.... txt不出现。 是否会成为问题? 我做了/检查了这一点: 克龙正在工作。 我用sudo“service cron start”commad检查了这个。 $ PATH包含“/home

get path after php script

I have search high and low for an answer to my question and I cannot find it. Basically what I want to do is get the path after a php script. ex. "http://www.example.com/index.php/arg1/arg2/arg3/etc/" and get arg1, arg2, arg3, etc in an array. How can I do this in php and once I do this will "http://www.example.com/arg1/arg2/arg3/etc" still return the same results. If not

在php脚本之后获取路径

我对搜索问题的答案有高有低,我无法找到答案。 基本上我想要做的是获得一个PHP脚本后的路径。 恩。 “http://www.example.com/index.php/arg1/arg2/arg3/etc/”并获取数组中的arg1,arg2,arg3等。 我怎么能在php中做到这一点,一旦我这样做,“http://www.example.com/arg1/arg2/arg3/etc”仍然会返回相同的结果。 如果不是,那我该如何实现呢? 以下是如何得到答案,以及将来有几个其他人。 制作一个脚本,例如“test.php”

Add path to PHP that all PHP scripts can access

I am trying to execute a command in php script. I got a command sh not found. I added the path in etc/sysconfig/httpd and it works for my php scripts in apache. How do I make it such that commands are available for scripts outside apache? I need to execute a php daemomn. I believe you can run it in this format: /path-to-your-php-install /path-to-your-script.php example: /usr/bin/php /home

添加所有PHP脚本都可以访问的PHP路径

我试图在PHP脚本中执行一个命令。 我找到了一个没有找到的命令。 我在etc / sysconfig / httpd中添加了路径,它适用于我在apache中的php脚本。 我如何使命令可用于apache之外的脚本? 我需要执行一个php daemomn。 我相信你可以用这种格式运行它: /path-to-your-php-install /path-to-your-script.php 例如: /usr/bin/php /home/whatever/public_html/script.php 我想你可以通过使用which php命令来确定你的PHP安装

PHP iOS AES Encryption

I've been having trouble trying to communicate between PHP and my iOS application using AES encryption. So far, I've considered two methods of implementation. The first was to use OpenSSL. On the iOS side, I implemented in a way to mimic the code shown here: http://saju.net.in/code/misc/openssl_aes.c.txt. On the PHP side, I took the generated key and IV (from the iPhone) and used i

PHP iOS的AES加密

尝试使用AES加密在PHP和我的iOS应用程序之间进行通信时遇到了问题。 到目前为止,我已经考虑了两种实现方法。 第一个是使用OpenSSL。 在iOS端,我以一种模仿这里显示的代码的方式实现:http://saju.net.in/code/misc/openssl_aes.c.txt。 在PHP方面,我将生成的密钥和IV(来自iPhone)并将其用作PHP openssl加密的输入。 结果在输出方面有所不同... 我也考虑过:http://iphonedevelopment.blogspot.com/2009/02/stron

Using the data mapper pattern

If I have a User, and a UserMapper. Would I hash the password outside the class, set the hashed password on the User set method and then save the User with the UserMapper, or would I implement the Hash method to the User (data holder) class and then save with UserMapper. Or lastly, would I Hash in the save() method in the UserMapper? What is the correct way when implementing the Data mapper pa

使用数据映射器模式

如果我有一个用户和一个UserMapper。 我会在课堂外哈希密码,在用户设置方法上设置哈希密码,然后用UserMapper保存用户,或者我将Hash方法实现到用户(数据持有者)类,然后使用UserMapper保存。 或者最后,我会在UserMapper的save()方法中散列吗? 实现Data Mapper模式时的正确方法是什么? 这是用户数据持有者: class User implements UserInterface { protected $id; public function __construct($row = nu

Data mapper and zend framework

I am implementing the Data Mapper design pattern in my Zend Framework web application, and everything goes well, I am really enjoying working with the data mapper in Zend and not applying only the Row Gateway pattern, but I am having a problem regarding my architecture. I am not sure how to reference and work with foreign key constraints in a OOP fashion with my data mapper. So I am having my M

数据映射器和zend框架

我在我的Zend Framework Web应用程序中实现了Data Mapper设计模式,并且一切都很顺利,我非常喜欢在Zend中使用数据映射器,而不是仅应用Row Gateway模式,但是我的架构存在问题。 我不确定如何使用我的数据映射器以OOP方式引用和处理外键约束。 所以我有我的Model类,我的DbTable类和我的Mapper类。 我应该将所有外键关系放在我的DbTable类中,这样我可以使用findDependentRowset()函数在映射器中检索,或者更好的方法是在映

PHP test for fatal error

This is a bit of a long shot, but I figured I'd ask anyway. I have an application that has web-based code editing, like you find on Github, using the ACE editor. The problem is, it is possible to edit code that is within the application itself. I have managed to detect parse errors before saving the file, which works great, but if the user creates a runtime error, such as MyClass extends

PHP测试致命错误

这有点远,但我想我仍然会问。 我有一个基于Web的代码编辑的应用程序,就像你在Github上使用ACE编辑器一样。 问题是,可以编辑应用程序本身内的代码。 在保存文件之前,我已经设法检测到分析错误,这很好,但如果用户创建运行时错误(如MyClass extends NonExistentClass ,文件将通过分析检查,但保存到文件系统中,从而终止应用程序。 无论如何要测试新代码在将其保存到文件系统之前是否会导致运行时错误? 似乎完全违

Handling items in the collection pattern by a data mapper

My question is related to the update section of @tereško's answer in "Who should handle the conditions in complex queries, the data mapper or the service layer?" Below is the code for reference and convenience. $category = new Category; $category->setTitle( 'privacy' ); $list = new ArticleCollection; $list->setCondition( $category ); $list->setDateRange( mktime( 0, 0, 0

通过数据映射器处理集合模式中的项目

我的问题与@tereško在“谁应该处理复杂查询中的条件,数据映射器或服务层?”中的答案有关。 以下是供参考和方便的代码。 $category = new Category; $category->setTitle( 'privacy' ); $list = new ArticleCollection; $list->setCondition( $category ); $list->setDateRange( mktime( 0, 0, 0, 12, 9, 2001) ); // it would make sense, if unset second value for range of dates // would default to NOW() in

PHP Mapper Pattern, many to many relationships

When using the mapper pattern, what is the best practice for defining classes for many to many relationships. For example, let's say we have tables for Products and Categories and Product_Categories Here are some basic skeletons for Products and Categories. Each has an object class and each has a Mapper. Product Object & Product Mapper: class Product { public $product_id;

PHP Mapper模式,多对多的关系

在使用映射器模式时,为多对多关系定义类的最佳做法是什么。 例如,假设我们有产品和类别以及Product_Categories的表格 以下是产品和类别的一些基本框架。 每个对象都有一个对象类,每个对象都有一个Mapper。 产品对象和产品映射器: class Product { public $product_id; public $name; public function __construct($product_id = false, $name = false) { $this->product_id = $product_i