PodsData::reorder PHP Method

reorder() public method

Reorder Items
Since: 2.0
public reorder ( string $table, string $weight_field, string $id_field, array $ids ) : boolean
$table string Table name
$weight_field string
$id_field string
$ids array
return boolean
    public function reorder($table, $weight_field, $id_field, $ids)
    {
        $success = false;
        $ids = (array) $ids;
        list($table, $weight_field, $id_field, $ids) = $this->do_hook('reorder', array($table, $weight_field, $id_field, $ids));
        if (!empty($ids)) {
            $success = true;
            foreach ($ids as $weight => $id) {
                $updated = $this->update($table, array($weight_field => $weight), array($id_field => $id), array('%d'), array('%d'));
                if (false === $updated) {
                    $success = false;
                }
            }
        }
        return $success;
    }