This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```php | |
<?php | |
# Be careful. This stuff is powerful and possibly dangerous. Good Luck ! | |
if (false && $_SERVER['REMOTE_ADDR'] == '146.0.115.137') { | |
error_reporting(-1); | |
ini_set('display_errors', true); | |
defined('YII_DEBUG') or define('YII_DEBUG', true); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```php | |
class ReminderCest | |
{ | |
public function _before(UnitTester $I) | |
{ | |
} | |
public function _after(UnitTester $I) | |
{ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In a view file i got: | |
```php | |
<?= Yii::t('app', '<i class="fa fa-download text-orange" aria-hidden="true"></i> <span class="productdownloads ml5">' . ($product->download_count > 0 ? $product->download_count : 0) . ' ' . Yii::t('app', 'Downloads') . '</span>'); ?> | |
``` | |
Of course. This is WRONG. I know. But yii/extract should handle it... - anyway, it leads to this error: | |
``` | |
Extracting messages from /var/www/html/hydra/views/products/view.php... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$shop_id = 246, | |
$sql = ''; | |
if (($handle = fopen("DATEI.csv", "r")) !== FALSE) { | |
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { | |
$sql = sprintf('insert into ratings (comment, shop_id, score, import_date, rating_date) | |
values("%s", "%s", "%s", "%s", "%s")', | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Wie kann ich das besser machen? | |
```php | |
if (isset(Yii::$app->user) | |
&& isset(Yii::$app->user->identity) | |
&& isset(Yii::$app->user->identity->profile) | |
&& isset(Yii::$app->user->identity->profile->language) | |
) { | |
$language = Yii::$app->user->identity->profile->language; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```php | |
if ($attribute) { | |
if($attribute->type != '') { | |
$super[Yii::t('app', $attribute->type)][] = Yii::t('app', $attribute->title); | |
} else { | |
$super[Yii::t('app', 'Allgemein')][] = Yii::t('app', $attribute->title); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function behaviors() | |
{ | |
return [ | |
[ | |
'class' => TimestampBehavior::className(), | |
'attributes' => [ | |
ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'], | |
ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'], | |
], | |
// if you're using datetime instead of UNIX timestamp: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
repositories": [ | |
{ | |
"type": "vcs", | |
"url": "https://github.com/thyseus/yii2-user" | |
}, | |
{ | |
"type": "vcs", | |
"url": "https://github.com/thyseus/yii2-audit" | |
} | |
], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
User::find()->where('id != 1')->andWhere(['or', ['>', 'age', 40], ['<', 'age', 20]])->all(); | |
"SELECT * FROM `users` WHERE (id != 1) AND ((`age` > :qp0) OR (`age` < :qp1))" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rätsel für Anfänger: | |
$a = false; | |
$b = true; | |
$c = $a or $b; | |
echo $c; | |
Rätsel für fortgeschrittene: | |
floor((0.1+0.7)*10); | |
(Lösung: floor(bcadd(0.1, 0.7, 1) * 10); ) |
NewerOlder