Ejemplo n.º 1
0
function &keysToLower(&$obj)
{
    $type = (int) is_object($obj) - (int) is_array($obj);
    if ($type === 0) {
        return $obj;
    }
    foreach ($obj as $key => &$val) {
        $element = keysToLower($val);
        switch ($type) {
            case 1:
                if (!is_int($key) && $key !== ($keyLowercase = strtolower($key))) {
                    unset($obj->{$key});
                    $key = $keyLowercase;
                }
                $obj->{$key} = $element;
                break;
            case -1:
                if (!is_int($key) && $key !== ($keyLowercase = strtolower($key))) {
                    unset($obj[$key]);
                    $key = $keyLowercase;
                }
                $obj[$key] = $element;
                break;
        }
    }
    return $obj;
}
Ejemplo n.º 2
0
 protected function standardRemap($remapTable, $removesTable, $foreignKey, $startId)
 {
     $totalAffectedRows = 0;
     $totalRows = $this->pdo->getTotalRows($removesTable);
     if (is_null($this->db->table($removesTable)->find($startId))) {
         $i = $this->pdo->getNextId(1, $removesTable);
     } else {
         $i = $startId;
     }
     while ($i) {
         $removalRow = keysToLower($this->db->table($removesTable)->find($i));
         $newId = $removalRow['new_id'];
         $affectedRows = $this->db->table($remapTable)->where($foreignKey, $i)->update([$foreignKey => $newId]);
         $feedback = $affectedRows ? 'feedback' : 'info';
         $this->{$feedback}('Updated from ' . $removesTable . '.id = ' . $i . ' (' . $affectedRows . ' rows updated)');
         $totalAffectedRows += $affectedRows;
         $i = $this->pdo->getNextId($i, $removesTable);
     }
     return $totalAffectedRows;
 }