You may optionally enter a comparison operator (<, <=, >, >=, <> or =) at the beginning of each of your search values to specify how the comparison should be done.
import json
myJSONFile = "/tmp/Test/myData.json"
json_data = open(myJSONFile)
# In Python werden JSON Daten nach dem Laden wie Dictionaries behandelt
data_dict = json.load(json_data)
echo gethostname();
// prints myComputer1 or srvLinux1
226
T-SQL
Systeminfo
Hostnamen ermitteln
SELECT HOST_NAME() AS Hostname;
-- prints myComputer1 or srvWindows1
227
PowerShell
Systeminfo
Hostnamen ermitteln
$myHostname = [system.environment]::MachineName;
write-host $myHostname;
# prints MyComputer1 or srvWindows2
249
Python
Systeminfo
Betriebssystem ermitteln
import os
os.name
# nt, posix
import platform
platform.system()
# 'Windows', 'Linux', 'Darwin'
platform.release()
# Linux, Windows, Windows, Darwin
'2.6.22-15-generic', 'Vista' ,'10', '8.11.1'
# Example from https://stackoverflow.com/questions/1854/python-what-os-am-i-running-on
from sys import platform as _platform
if _platform == "linux" or _platform == "linux2":
# linux
elif _platform == "darwin":
# MAC OS X
elif _platform == "win32":
# Windows
elif _platform == "win64":
# Windows 64-bit
253
T-SQL
Metadaten
Fremdschlüssel auflisten
SELECT
[FK_NAME] = obj.name
,[Schema_Name] = sch.name
,[Table] = tab1.name
,[Column] = col1.name
,[Referenced_Schema_Name] = sch2.name
,[Referenced_Table] = tab2.name
,[Referenced_Column] = col2.name
FROM sys.foreign_key_columns fkc
INNER JOIN sys.objects obj
ON obj.object_id = fkc.constraint_object_id
INNER JOIN sys.tables tab1
ON tab1.object_id = fkc.parent_object_id
INNER JOIN sys.schemas sch
ON tab1.schema_id = sch.schema_id
INNER JOIN sys.columns col1
ON col1.column_id = parent_column_id AND col1.object_id = tab1.object_id
INNER JOIN sys.tables tab2
ON tab2.object_id = fkc.referenced_object_id
INNER JOIN sys.columns col2
ON col2.column_id = referenced_column_id AND col2.object_id = tab2.object_id
INNER JOIN sys.schemas sch2
ON tab2.schema_id = sch.schema_id
286
Yii2
Yii2-ActiveQuery
Abfrage mit Subselect
<?php
/*
SQL Example:
SELECT * FROM `Cities`
WHERE
(`postalcode_id` IN (SELECT `id` FROM `postalcodes` WHERE `postalcode`='12345')
)
OR
(`region_id` IN (SELECT `id` FROM `regions` WHERE `region`='North')
)
*/
$active_query_postalcodes_For_Subselect = \app\models\Postalcodes::find()->select("id")->where(["postalcodes" => '12345']); // Attention! No "->all()" at the end to create a subselect!
$active_query_regions_For_Subselect = \app\models\Regions::find()->select("id")->where(["region" => 'North']); // Attention! No "->all()" at the end to create a subselect!
$model = new \app\models\Cities();
$all_Cities_With_IN_and_OR = $model::find()
->where(['in', "postalcode_id", $active_query_postalcodes_For_Subselect])
->orWhere(['in', "region_id", $active_query_regions_For_Subselect])
->all();
?>
292
Yii2
Yii2-Internal
Prüfen ob aktueller User ein Gast ist
use Yii;
if (! \Yii::$app->user->isGuest)
{
$result = "User is logged in. User is no guest"
}