Skip to content

Instantly share code, notes, and snippets.

View thyseus's full-sized avatar
💭
Linux Rules

Herbert Maschke thyseus

💭
Linux Rules
  • Leipzig, Germany
View GitHub Profile
```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);
}
```php
class ReminderCest
{
public function _before(UnitTester $I)
{
}
public function _after(UnitTester $I)
{
}
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...
$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")',
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;
```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);
}
}
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:
repositories": [
{
"type": "vcs",
"url": "https://github.com/thyseus/yii2-user"
},
{
"type": "vcs",
"url": "https://github.com/thyseus/yii2-audit"
}
],
User::find()->where('id != 1')->andWhere(['or', ['>', 'age', 40], ['<', 'age', 20]])->all();
"SELECT * FROM `users` WHERE (id != 1) AND ((`age` > :qp0) OR (`age` < :qp1))"
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); )