I would like to create a query with Yii relations. This is my relation: //Articles model return array( 'articlesHasTags' => array(self::HAS_MANY, 'ArticlesHasTag', 'articles_id', "with"=>"tag", ), ), //ArticlesHasTag model return array( 'articles' => array(self::BELONGS_T
我想用Yii关系创建一个查询。 这是我的关系: //Articles model return array( 'articlesHasTags' => array(self::HAS_MANY, 'ArticlesHasTag', 'articles_id', "with"=>"tag", ), ), //ArticlesHasTag model return array( 'articles' => array(self::BELONGS_TO, 'Articles', 'articles_id')
I need to select from the database values on such a request "select * from prem_message where to_id 12 and del_to 0"? I writed this query but it is incorrect, please correct it by writing: $criteria = new CDbCriteria(); // Select a fields from the database $criteria->select='id'; $criteria->select='from_id'; $criteria->select='to_id';
我需要从数据库值中选择这样一个请求“select * from prem_message where to_id 12 and del_to 0”? 我编写了这个查询,但它不正确,请通过编写来纠正它: $criteria = new CDbCriteria(); // Select a fields from the database $criteria->select='id'; $criteria->select='from_id'; $criteria->select='to_id'; $criteria->select='msg'; $criteria-&
I'm trying to select data from two tables and show that data in a paginated grid view. The problem is that Yii is joining the data with a SQL join (because I told it to do it) and because of that it's not showing the correct number of items per page. To make in clear, I'm selecting from topics and messages_in_topics , and I'm joining then with $criteria->together = true;
我试图从两个表中选择数据,并在分页的网格视图中显示数据。 问题在于Yii使用SQL连接加入数据(因为我告诉它这样做),并且因为它没有显示每页正确数量的项目。 为了明确,我正在从topics和messages_in_topics选择,然后我将加入 $criteria->together = true; 这使得MySQL为每条消息(和相关主题)返回一行。 例: id_topic topic id_messages message 1 topic1 1 message1_in_to
I made a table called "Customer" and I want to make a simple Yii application of create and view. Here's the piece of my code in CustomerController.php: class CustomerController extends Controller { public $layout = '//layouts/column2'; public function actionCreate() { $model = new Customer(); $this->redirect(array('view', 'id' => $model->id
我制作了一张名为“Customer”的表格,我想制作一个简单的Yii创建和查看应用程序。 以下是我在CustomerController.php中的一段代码: class CustomerController extends Controller { public $layout = '//layouts/column2'; public function actionCreate() { $model = new Customer(); $this->redirect(array('view', 'id' => $model->id)); $this->render('create', arr
This is a more of a coding style question for projects using MVC architecture. I'm working on a project using Yii framework. Each database table has it's own model class and lets me take advantage of Yii's Active Record stuff. Cool. But now I need to do an SQL query with a complex logic and a lot of tables being joined. The best and quickest way to do this is to write a raw SQL
对于使用MVC体系结构的项目,这是更多的编码风格问题。 我正在使用Yii框架开展一个项目。 每个数据库表都有它自己的模型类,可以让我充分利用Yii的活动记录。 凉。 但是现在我需要用一个复杂的逻辑和大量的表进行SQL查询。 最好和最快捷的方法是编写一个原始SQL,并将其放入一些getSomeComplexLogicData方法中。 问题是,我在哪里放这个方法? 将它放在一个我称之为控制器的地方是很好的做法(它不太可能会在其他地方
On our websites we want to make it possible to share sessions accros multiple domains. All these websites are on the same server but some of them have a different IP address. The possible solution I found was to set the session ID myself: <?php session_id($someUniqueHash); ?> And this works, if I make the hash like md5('test'). On a other domain on te same server we have the s
在我们的网站上,我们希望能够分享会话accros多个域。 所有这些网站都在同一台服务器上,但其中一些具有不同的IP地址。 我找到的可能解决方案是自己设置会话ID: <?php session_id($someUniqueHash); ?> 如果我像md5('test')那样创建散列,这是有效的。 在同一台服务器上的其他域上,我们再次进行会话。 问题是生成ID。 我在互联网上看到了microtime等的一些解决方案,但是当我使用这种方法时,我无法
I want use html5's new tag to play a wav file (currently only supported in FF.) https://developer.mozilla.org/En/HTML/Element/Audio I"m using php's readfile command to get the wav file off the hdd, and write it to the http response. But its not working. The audio widget in firefox just has the loading animation running constantly. The tag seems to be fine as I can put a diff
我想用html5的新标签播放一个wav文件(目前只支持FF)。 https://developer.mozilla.org/En/HTML/Element/Audio 我使用php的readfile命令将wav文件从硬盘驱动器中取出,并将其写入http响应中。 但它不工作。 在Firefox中的音频小部件只是加载动画不断运行。 该标签似乎没有问题,因为我可以在它的src / source中添加一个不同的url,并且它可以正常工作。 我可以使用标签并下载文件,并使用Quicktime进行播放。 所以
I want to write a web application to play chess against the engine Crafty. I'm not new to PHP and javascript, but must learn how to interact with a server process : how can a web application and/or (jQuery) ajax interact bi-directionally with a (linux) program running on the server? At this moment i am developing on (Apache) local host. Crafty is installed on my Ubuntu PC. This well-know
我想编写一个web应用程序来对抗引擎Crafty玩象棋。 我并不陌生于PHP和JavaScript,但必须学习如何与服务器进程交互:Web应用程序和/或(jQuery)ajax如何与运行在服务器上的(linux)程序双向交互? 目前我正在开发(Apache)本地主机。 Crafty安装在我的Ubuntu PC上。 这个着名的国际象棋引擎没有GUI,它通过命令在终端运行 $ / usr / games / crafty 所以你可以对它下棋,甚至看到它的计算: 我可以通过PHP使用函数
Does using namespaces make a site faster or slower? That's what I would like to know. If it helps improving site performance, then i would like to start using it right now. But if it degrades it, then i don't want to use it at all - even a little performance makes big difference in my project. Dos anyone have a benchmark on this? What are your views? PHP Namespaces are largely if
使用名称空间是否会使网站更快或更慢? 这就是我想知道的。 如果它有助于改善网站性能,那么我现在就想开始使用它。 但是,如果它降级了,那么我根本不想使用它 - 即使是一点点的表现也会在我的项目中产生重大影响。 有没有人有这方面的基准? 你有什么看法? PHP名称空间在很大程度上与您网站的性能无关。 他们帮助你编写封装良好的结构化代码 - 这就是为什么你不应该害怕使用它们,至少如果你的项目达到了一定的复杂
I have the following c# code that generates keys: public static byte[] Encrypt(byte[] plainData, string salt) { DESCryptoServiceProvider DES = new DESCryptoServiceProvider(); DES.Key = ASCIIEncoding.ASCII.GetBytes(salt); DES.IV = ASCIIEncoding.ASCII.GetBytes(salt); ICryptoTransform desencrypt = DES.CreateEncryptor(); byte[] encryptedData = desencry
我有以下生成密钥的c#代码: public static byte[] Encrypt(byte[] plainData, string salt) { DESCryptoServiceProvider DES = new DESCryptoServiceProvider(); DES.Key = ASCIIEncoding.ASCII.GetBytes(salt); DES.IV = ASCIIEncoding.ASCII.GetBytes(salt); ICryptoTransform desencrypt = DES.CreateEncryptor(); byte[] encryptedData = desencrypt.TransformFinalBlock