Yii

How to prevent mysql injection when using mysql IN clause without activeRecord in Yii?

烈酒焚心 提交于 2019-12-24 18:03:41
问题 I have an array with ids that I get from client. And I want use those ids in my sql query with IN clause. But this query goes on a table that has no model. So there is no active record (criteria) query possible. ** Table userTasks ** -------------------- | idUser | idTasks | ---------+---------- | 1 | 1 | ---------+---------- | 1 | 2 | ---------+---------- | 1 | 3 | ---------+---------- First approach does not work because params are always considered as strings. So :tasks is a string '1,2,3'

Sorting a date column in CGridView with CArrayDataProvider

断了今生、忘了曾经 提交于 2019-12-24 16:53:16
问题 I'm using a CGridView on a website to display data provided via a CArrayDataProvider. Reason for this is, that the data is cumulated across different tables and enriched with additional computed columns. Sorting and Filtering is generally working fine with this code (... are omitted columns): $this->widget('zii.widgets.grid.CGridView', array( 'id'=>'produkt-grid', 'dataProvider'=>new CArrayDataProvider($betroffeneProdukte, array( 'sort' => array( 'attributes' => array( 'bezeichnung', 'datum',

Yii file upload is not validating file type

ⅰ亾dé卋堺 提交于 2019-12-24 16:21:57
问题 I am validating the file type to be uploaded. The validation rule does not seem to work. I only want to accept jpg files but when I try putting pdf files, it still accepts it and does not give any error. Please help. I don't know what I'm doing wrong. View: <?php $form=$this->beginWidget('CActiveForm', array( 'id'=>'document-form', 'enableAjaxValidation'=>true, 'enableClientValidation'=>true, 'clientOptions'=>array('validateOnSubmit'=>true), //This is very important 'htmlOptions'=>array(

Yii i want to get all actions that a user is authorized to perform

有些话、适合烂在心里 提交于 2019-12-24 16:06:48
问题 how can i get back the actions i defined in my accessrules function public function accessRules(){ return array( 'allow', 'actions'=>array('create','update' ...), .... ) } i need them for dislay reason something like if(in_array('create',$actions)) echo CHtml::link('link to create form') or may be something like if(user->isAutorizedToPerfoem('create')). thanx in advance 回答1: I think this is not possible when you use the accessControl filter. The authorization data is in this case saved

CDATA being added automatically on JS in Yii?

瘦欲@ 提交于 2019-12-24 16:02:32
问题 I am coding in Yii and whenever I put any JS it tags it in CDATA. Why is it getting added automatically? and will there be any problem if I remove it as I write my markup in HTML5. 回答1: Like what arnaud said in the comment if the question, it wont affect your html 5 code. So its okay. In addition, cdata tags are quite necessary to be used for scripts in XML, so its actually a feature from Yii. 来源: https://stackoverflow.com/questions/16656317/cdata-being-added-automatically-on-js-in-yii

Yii, attaching a javascript function on submit button

做~自己de王妃 提交于 2019-12-24 15:42:46
问题 I want to attach a function to my submit button. But my code doesn't seem to be calling the function. Basically what I want it to do is, enabling all disabled field when the form is being submitted. This below is my code: <script> function enableField() { $("#Booking_clientPackagedService_id").prop("disabled", false); } </script> <?php echo CHtml::submitButton(Yii::t('app', 'Save')); $this->endWidget(); ?> This #Booking_clientPackagedService_id initially is disabled after certain action being

Reading Multiply Rows From Database On Yii Framework

大兔子大兔子 提交于 2019-12-24 15:24:03
问题 I think database operations isn't explained very well, on guide . I couldn't understand it. Because of this i have a question. I asked it Yii Forums but there isn't any answer. This is my socials table for example. +------------+---------------------------+--------------+--------------+---------------+ | socials_ID | socials_link | socials_type | socials_user | socials_order | +------------+---------------------------+--------------+--------------+---------------+ | 48 | link | 8 | 1 | 4 | |

Encrypt PHP source code in Yii

无人久伴 提交于 2019-12-24 14:22:42
问题 Is there any Yii specific ways available to encrypt the source code? I do not want my client to see my source code. I want to encrypt all my PHP files and codes. Any idea? 回答1: Use Zend Guard.Best way to encrypt all PHP Source codes. Other methods are Ion Cube Source Guardian phpSHIELD 回答2: Surley there are ways to encode the project like Zend Guard and IonCube but you will have to pay for them and yes while encrypting the code do not forget the Yii license 来源: https://stackoverflow.com

yii multiple inner joins

萝らか妹 提交于 2019-12-24 14:03:02
问题 I am trying to write a query in yii. I have the following which works $criteria = new CDbCriteria; $criteria->condition = "($column = :id)"; $criteria->params = array(":id" => $id ); $rows = Jobs::model()->with('pROJ')->findAll($criteria); This returns the model of Jobs in array. I need to write the following query in yii to return a model SELECT jobs.JOBNO, jobs.STATUS, projects.ORDERNO, jobs.PROJID, jobs.NAME, jobs.SEQ, jobs.PCENTDONE, jobs.EARNED, jobs.VALUE, jobs.DATEIN, jobs.DATEDONE,

Fatal error: Class 'CModelEvent' not found in CModel.php on line 189

给你一囗甜甜゛ 提交于 2019-12-24 13:33:29
问题 I get this error(Fatal error: Class 'CModelEvent' not found) whenever I try to save model without using a post form but directly get data from an excel file and assign it to model attributes as given below: public function actionImportFile() { if (isset($_POST['User'])) { Yii::import('application.extensions.yii-phpexcel.PHPExcel', true); $objPHPExcel = PHPExcel_IOFactory::load($_FILES['User']['tmp_name']['import_file']); $objWorksheet = $objPHPExcel->getActiveSheet(); $model = new User(