Пример #1
0
        echo 'Populating the entity table<br/>';
        $fields = array('location' => 'tinytext', 'price' => 'decimal(10,2)', 'classified_print_content' => 'text', 'classified_date_available' => 'datetime', 'classified_duration_days' => 'int', 'classified_contact_email' => 'tinytext', 'display_contact_info' => 'boolean');
        foreach ($fields as $key => $value) {
            $fields[$key] = array('db_type' => $value);
        }
        $updater = new FieldToEntityTable('classified_table', $fields);
        $updater->update_entity_table();
        $updater->report();
    }
    echo 'Checking for classified category type... ';
    if (reason_unique_name_exists('classified_category_type')) {
        echo 'Classified category type already exists. Proceeding.<br/>';
        $classified_category = id_of('classified_category_type');
    } else {
        echo 'Creating classified category type.<br/>';
        $classified_category = create_type($admin_site, id_of('type'), $user, 'Classified Category', array('new' => 0, 'plural_name' => 'Classified categories', 'unique_name' => 'classified_category_type'));
        echo 'Creating allowable relationship with classifieds<br/>';
        create_allowable_relationship($classified, $classified_category, 'classified_to_classified_category');
    }
    echo 'Putting entity tables on classified type<br/>';
    $rel = relationship_id_of('type_to_table');
    foreach (array('classified_table', 'meta', 'chunk', 'dated') as $t) {
        if (name_exists($t)) {
            create_relationship($classified, id_of_name($t), $rel);
        } else {
            echo "Missing name {$t}!<br/>";
        }
    }
    echo "Install was successful!<br/>";
}
?>
Пример #2
0
<?php

//echo "0 ";
$connection = new PDO("mysql:host=localhost;dbname=peeps", "root", "");
switch ($_POST["function_to_be_called"]) {
    case "create":
        create_type(trim($_POST['new_trait']), (bool) $_POST['discrete']);
        break;
    case "list":
        display_all();
        break;
    case "delete":
        delete($_POST['type']);
        break;
    case "delete_trait":
        delete_trait($_POST['id']);
        break;
    case "change_rank":
        change_rank($_POST['id'], $_POST['is_direction_up']);
        break;
    case "create_trait":
        create_trait($_POST['profile_id'], $_POST['trait_id'], $_POST['trait_type'], $_POST['trait_value'], $_POST['trait_discrete']);
        break;
}
function change_rank($id, $is_direction_up)
{
    global $connection;
    $statement = $connection->prepare("select * from traits where id=?");
    $statement->bindValue(1, $id, PDO::PARAM_INT);
    $statement->execute();
    $main_record = $statement->fetchObject();