Yii

Postgres error: null value in column “id” - during insert operation

99封情书 提交于 2020-06-11 16:18:55
问题 I use postgresql and yii2 framework. Well I got a very interesting error message: SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column "id" violates not-null constraint DETAIL: Failing row contains (null, 1, null, null, null, null, 1, Demo, , , , 1998-01-01, , , , 345345435453453, , , , , 1, , , f, f, f, f, 10, f, 1, f, f, f, null, null, null, 1470477479, 1470477479, null). But I checked my Insert command, and there is not "id" column there! INSERT INTO "advertiser" ("languages"

Yii echmultiselect showing error on console and not working

落花浮王杯 提交于 2020-06-01 07:41:06
问题 I was following the Option no 3 here https://www.yiiframework.com/extension/echmultiselect#3-use-as-a-filter-in-cgridview to add multiselect dropdown on my Yii project. But it is showing, jquery.js:6920 Uncaught TypeError: jQuery.easing[this.easing] is not a function at init.run (jquery.js:6920) On my cgridview , this is the column that has to be multiple select checkbox, array ( 'name'=>'brand_id', 'filter'=> $this->widget('ext.EchMultiSelect.EchMultiSelect', array( 'model' => $model,

Get all table names in yii

跟風遠走 提交于 2020-05-15 04:04:27
问题 How to get all table names in yii? The sql query in mySQL is SHOW TABLES . I tried: $sql = 'SHOW TABLES'; $tables = Yii::app()->db ->createCommand($sql) ->queryAll(); print_r($tables); It throws an error: CDbCommand failed to execute the SQL statement: CDbCommand failed to prepare the SQL statement: SQLSTATE[HY000]: General error: 1 near "SHOW": syntax error. The SQL statement executed was: SHOW TABLES 回答1: try this one: $connection = Yii::app()->db;//get connection $dbSchema = $connection-

Get all table names in yii

早过忘川 提交于 2020-05-15 04:04:09
问题 How to get all table names in yii? The sql query in mySQL is SHOW TABLES . I tried: $sql = 'SHOW TABLES'; $tables = Yii::app()->db ->createCommand($sql) ->queryAll(); print_r($tables); It throws an error: CDbCommand failed to execute the SQL statement: CDbCommand failed to prepare the SQL statement: SQLSTATE[HY000]: General error: 1 near "SHOW": syntax error. The SQL statement executed was: SHOW TABLES 回答1: try this one: $connection = Yii::app()->db;//get connection $dbSchema = $connection-

Get all table names in yii

痴心易碎 提交于 2020-05-15 04:04:07
问题 How to get all table names in yii? The sql query in mySQL is SHOW TABLES . I tried: $sql = 'SHOW TABLES'; $tables = Yii::app()->db ->createCommand($sql) ->queryAll(); print_r($tables); It throws an error: CDbCommand failed to execute the SQL statement: CDbCommand failed to prepare the SQL statement: SQLSTATE[HY000]: General error: 1 near "SHOW": syntax error. The SQL statement executed was: SHOW TABLES 回答1: try this one: $connection = Yii::app()->db;//get connection $dbSchema = $connection-

mPDF temporary file is not writable using Yii

不羁岁月 提交于 2020-05-13 06:27:57
问题 I tried to print a certificate in PDF but when I push my code to staging, it said Temporary files directory "/var/www/protected/vendor/mpdf/mpdf/src/Config/../../tmp" is not writable I'm not sure how to change the permission and how to change the custom directory. Here's my code of a button to click to get the certificate: <a class="btn btn-sd btn-sd-ghost btn-sd-ghost-black margin-right-lg" href="<?php echo $this->createUrl('//idea/frontend/pdf', array('id'=>$model->id))?>" target="_blank"

mPDF temporary file is not writable using Yii

╄→гoц情女王★ 提交于 2020-05-13 06:25:28
问题 I tried to print a certificate in PDF but when I push my code to staging, it said Temporary files directory "/var/www/protected/vendor/mpdf/mpdf/src/Config/../../tmp" is not writable I'm not sure how to change the permission and how to change the custom directory. Here's my code of a button to click to get the certificate: <a class="btn btn-sd btn-sd-ghost btn-sd-ghost-black margin-right-lg" href="<?php echo $this->createUrl('//idea/frontend/pdf', array('id'=>$model->id))?>" target="_blank"

HTML2PDF doesn't recognize tables' sizes

筅森魡賤 提交于 2020-05-11 04:56:46
问题 I'm working in a web page developed using Yii Extension and I'm using the HTML2PDF extension to generate PDFs (http://html2pdf.fr/). Though the PDF is generated fine, it doesn't seem to recognize my tables' sizes; doesn't matter the width or height I specify for a row or a whole table: the PDF is always generated the same way (with a table width that just fits the cell content)... Here is how I'm trying to specify the width: <table width="500px" height="20px" style="margin:10px;"> <tr> <td

依赖注入与哪些事情无关?

我只是一个虾纸丫 提交于 2020-05-08 18:54:57
任何你使用的现代框架,都可能严重依赖于依赖注入。但是你知道依赖注入代表的真正含义吗?或者换一个更好的角度 - 你知道依赖注入不是什么吗? 依赖容器 虽然每个现代框架都附带依赖容器 — 一个用于构建对象的大盒子 — 但这并不能保证你会按照预期的方式使用依赖注入模式。 容器让依赖项更加容易注入到类中,但是它也可能被滥用。 服务定位器模式 一种滥用服务容器的方式是从容器中拉取对象,而不是注入到当前的上下文中。该模式称之为服务定位器模式,它与依赖注入相反。 class MyController { public function indexAction() { $service = app(Service::class); // … } }    服务定位器模式向容器请求特定的对象。这将导致服务从一个难以测试的点拉取,并且,对于外部而言这就像一个黑匣子:除非你查看全部相关代码,否则你将无法了解 MyController 所依赖的外部类型。 一些框架提倡这种用法,因为在项目开始的时候它将变得简单快捷。一旦在容器中注册了成百上千个类,使用服务定位器模式将会导致混乱。而使用依赖注入将解决该问题。 更多信息,可查看我写的这篇博客: 为什么服务定位器模式是反模式. 依赖共享 接下来是一些更积极的方面:以一种更好的方式使用容器。 当依赖注入被正确使用时,外部上下文 (在许多情况下为容器)

PHP 开启 Opcache 功能提升程序处理效率

♀尐吖头ヾ 提交于 2020-05-08 14:28:26
简介 Opcache 的前生是 Optimizer+ ,它是 Zend 开发的 PHP 优化加速组件。Optimizer+ 将 PHP 代码预编译生成的脚本文件 Opcode 缓存在共享内存中供以后反复使用,从而避免了从磁盘读取代码再次编译的时间消耗。同时,它还应用了一些代码优化模式,使得代码执行更快。从而加速 PHP 的执行。 正常的执行流程如下: 开启 Opcache 后的执行流程如下: Yum 安装 php -v yum list *opcache* yum -y install rh-php71-php-opcache.x86_64 kill -USR2 cat `/usr/local/php/var/run/php-fpm.pid` nginx -s reload 配置 zend_extension=opcache.so [opcache] ;开启opcache功能 opcache.enable=1 ;CLI环境下,开启opcache功能 opcache.enable_cli=1 ;OPcache共享内存的大小,单位MB opcache.memory_consumption=128 ;字符串在进程间驻留科使用的内存大小,单位MB opcache.interned_strings_buffer=8 ;内存中可以缓存的文件量。200-1000000之间 ;可以使用“find