+ /**
+ * @brief Returns the SQL condition string built from the provided condition array
+ *
+ * This function operates with two modes.
+ * - Supplied with a filed/value associative array, it builds simple strict
+ * equality conditions linked by AND.
+ * - Supplied with a flat list, the first element is the condition string and
+ * the following arguments are the values to be interpolated
+ *
+ * $condition = ["uid" => 1, "network" => 'dspr'];
+ * or:
+ * $condition = ["`uid` = ? AND `network` IN (?, ?)", 1, 'dfrn', 'dspr'];
+ *
+ * In either case, the provided array is left with the parameters only
+ *
+ * @param array $condition
+ * @return string
+ */
+ private static function buildCondition(array &$condition = [])
+ {
+ $condition_string = '';
+ if (count($condition) > 0) {
+ $array_element = each($condition);
+ $array_key = $array_element['key'];
+ if (is_int($array_key)) {
+ $condition_string = " WHERE ".array_shift($condition);
+ } else {
+ $condition_string = " WHERE `".implode("` = ? AND `", array_keys($condition))."` = ?";
+ }
+ }
+
+ return $condition_string;
+ }