<?php
+use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBM;
private static $in_transaction = false;
private static $relation = [];
- public static function connect($serveraddr, $user, $pass, $db, $install = false) {
+ public static function connect($serveraddr, $user, $pass, $db) {
if (!is_null(self::$db)) {
return true;
}
return false;
}
- if ($install) {
+ if ($a->mode == App::MODE_INSTALL) {
// server has to be a non-empty string that is not 'localhost' and not an IP
if (strlen($server) && ($server !== 'localhost') && filter_var($server, FILTER_VALIDATE_IP) === false) {
if (! dns_get_record($server, DNS_A + DNS_CNAME)) {
// No suitable SQL driver was found.
if (!self::$connected) {
+ self::$driver = null;
self::$db = null;
}
$a->save_timestamp($stamp1, "network");
*
* @param string $table Table name
* @param array $conditions Field condition(s)
+ * @param array $options
+ * - cascade: If true we delete records in other tables that depend on the one we're deleting through
+ * relations (default: true)
* @param boolean $in_process Internal use: Only do a commit after the last delete
* @param array $callstack Internal use: prevent endless loops
*
}
// Is there a relation entry for the table?
- if (isset(self::$relation[$table])) {
+ if ($cascade && isset(self::$relation[$table])) {
// We only allow a simple "one field" relation.
$field = array_keys(self::$relation[$table])[0];
$rel_def = array_values(self::$relation[$table])[0];
// Split the SQL queries in chunks of 100 values
// We do the $i stuff here to make the code better readable
$i = $counter[$key_table][$key_condition];
- if (count($compacted[$key_table][$key_condition][$i]) > 100) {
+ if (isset($compacted[$key_table][$key_condition][$i]) && count($compacted[$key_table][$key_condition][$i]) > 100) {
++$i;
}