Hotfix release available: 2026-07-14b "Mort".
upgrade now! [57.2] (what's this?)
onny:notizen:programmierung
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| onny:notizen:programmierung [2026/06/30 13:15] – [php] 10.250.0.1 | onny:notizen:programmierung [2026/08/18 11:23] (current) – [mariadb / mysql] fdc9:281f:4d7:9ee9::1 | ||
|---|---|---|---|
| Line 525: | Line 525: | ||
| printf string | printf string | ||
| + | |||
| <code php> | <code php> | ||
| printf(" | printf(" | ||
| Line 530: | Line 531: | ||
| print array | print array | ||
| + | |||
| <code php> | <code php> | ||
| $a = array (' | $a = array (' | ||
| print_r($a); | print_r($a); | ||
| + | </ | ||
| + | |||
| + | filter array only unique items | ||
| + | |||
| + | <code php> | ||
| + | $userIds = array_unique($userIds); | ||
| + | </ | ||
| + | |||
| + | append to array | ||
| + | |||
| + | <code php> | ||
| + | $fruits = [' | ||
| + | $fruits[] = ' | ||
| </ | </ | ||
| assosiative array / dictionary | assosiative array / dictionary | ||
| + | |||
| <code php> | <code php> | ||
| $myResult[" | $myResult[" | ||
| + | </ | ||
| + | |||
| + | datetime object, convert to string | ||
| + | |||
| + | <code php> | ||
| + | $date = new \DateTime(' | ||
| + | $dateString = $date-> | ||
| </ | </ | ||
| enable debugging / error log | enable debugging / error log | ||
| + | |||
| <file - / | <file - / | ||
| display_startup_errors = true | display_startup_errors = true | ||
| Line 553: | Line 577: | ||
| chmod a+w+r / | chmod a+w+r / | ||
| </ | </ | ||
| + | |||
| foreach loop | foreach loop | ||
| + | |||
| <code php> | <code php> | ||
| foreach($this-> | foreach($this-> | ||
| Line 563: | Line 589: | ||
| } | } | ||
| </ | </ | ||
| + | |||
| get array length | get array length | ||
| + | |||
| <code php> | <code php> | ||
| var_dump(count($a)); | var_dump(count($a)); | ||
| Line 569: | Line 597: | ||
| get type of variable | get type of variable | ||
| + | |||
| <code php> | <code php> | ||
| foreach($data as $episode) { | foreach($data as $episode) { | ||
| Line 576: | Line 605: | ||
| convert string to int | convert string to int | ||
| + | |||
| <code php> | <code php> | ||
| intval(" | intval(" | ||
| Line 586: | Line 616: | ||
| </ | </ | ||
| + | |||
| + | define class, create object | ||
| + | |||
| + | <code php> | ||
| + | class Calendar { | ||
| + | private array $data; | ||
| + | |||
| + | public function __construct(array $data) { | ||
| + | $this-> | ||
| + | } | ||
| + | |||
| + | public function getUserId(): | ||
| + | $principalUri = $this-> | ||
| + | $principalUriParts = explode('/', | ||
| + | $user = end($principalUriParts); | ||
| + | return $user; | ||
| + | } | ||
| + | |||
| + | public function getDisplayName(): | ||
| + | return $this-> | ||
| + | } | ||
| + | |||
| + | public function __debugInfo(): | ||
| + | // keeps print_r() useful | ||
| + | return $this-> | ||
| + | } | ||
| + | } | ||
| + | |||
| + | private function fetchCalendarById(int $calendarId) { | ||
| + | $query = $this-> | ||
| + | $query-> | ||
| + | -> | ||
| + | -> | ||
| + | $result = $query-> | ||
| + | $calendar = $result-> | ||
| + | $result-> | ||
| + | |||
| + | if (empty($calendar)) { | ||
| + | return false; | ||
| + | } | ||
| + | |||
| + | return new Calendar($calendar); | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | print and debug php database queries | ||
| + | |||
| + | <code php> | ||
| + | $query-> | ||
| + | -> | ||
| + | -> | ||
| + | |||
| + | printf(" | ||
| + | printf(" | ||
| + | </ | ||
| + | |||
| + | check if array key exists (avoid undefined warning) via "null casting" | ||
| + | |||
| + | <code php> | ||
| + | if ($config[' | ||
| + | </ | ||
| ==== nextcloud app dev ==== | ==== nextcloud app dev ==== | ||
| logging, available methods: emergency, alert, critical, error, warning, notice, info, debug | logging, available methods: emergency, alert, critical, error, warning, notice, info, debug | ||
| Line 618: | Line 709: | ||
| </ | </ | ||
| + | logging | ||
| + | |||
| + | <code php> | ||
| + | $this-> | ||
| + | ' | ||
| + | ' | ||
| + | ' | ||
| + | ]); | ||
| + | </ | ||
| ==== wordpress ==== | ==== wordpress ==== | ||
| registering menus | registering menus | ||
| Line 789: | Line 889: | ||
| </ | </ | ||
| - | ==== mysql ==== | + | ==== mariadb / mysql ==== |
| + | |||
| + | select column and sort alphabetically | ||
| + | |||
| + | < | ||
| + | SELECT user_id | ||
| + | FROM oc_user_oidc | ||
| + | ORDER BY user_id ASC; | ||
| + | </ | ||
| delete specific row | delete specific row | ||
| + | |||
| < | < | ||
| delete from oc_storages where numeric_id=58; | delete from oc_storages where numeric_id=58; | ||
| Line 797: | Line 906: | ||
| remove user | remove user | ||
| + | |||
| <code sql> | <code sql> | ||
| DROP USER ' | DROP USER ' | ||
| Line 802: | Line 912: | ||
| adjust permissions to table | adjust permissions to table | ||
| + | |||
| <code sql> | <code sql> | ||
| CREATE USER ' | CREATE USER ' | ||
| Line 815: | Line 926: | ||
| </ | </ | ||
| + | sort column by timestamp and convert to datetime | ||
| + | |||
| + | <code sql> | ||
| + | SELECT | ||
| + | `id`, | ||
| + | `calendarid`, | ||
| + | FROM_UNIXTIME(`firstoccurence`) AS firstoccurence, | ||
| + | FROM_UNIXTIME(`lastoccurence`) | ||
| + | FROM `oc_calendarobjects` | ||
| + | WHERE (`lastoccurence` < 1606694400) | ||
| + | AND (`firstoccurence` > 0) | ||
| + | AND (`componenttype` = ' | ||
| + | ORDER BY `lastoccurence` DESC; | ||
| + | </ | ||
onny/notizen/programmierung.1782825320.txt.gz · Last modified: by 10.250.0.1
