本文整理汇总了PHP中Dataset::setDatasetId方法的典型用法代码示例。如果您正苦于以下问题:PHP Dataset::setDatasetId方法的具体用法?PHP Dataset::setDatasetId怎么用?PHP Dataset::setDatasetId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dataset
的用法示例。
在下文中一共展示了Dataset::setDatasetId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDatasetsArray
public static function getDatasetsArray($rows)
{
$datasets = array();
if (!empty($rows)) {
// Convert the array of arrays into an array of Datasets
// and set the id and date_created fields
foreach ($rows as $datasetRow) {
$dataset = new Dataset($datasetRow);
$datasetId = $datasetRow['dataset_id'];
$dataset->setDatasetId($datasetId);
$datasetDateCreated = $datasetRow['date_created'];
$dataset->setDateCreated($datasetDateCreated);
// TODO: We should also get the dataset's associated sensors
// Coordinate this in the controller
array_push($datasets, $dataset);
}
}
return $datasets;
}
示例2: updateDataset
private function updateDataset()
{
$dataset = $_SESSION['dataset'];
if (empty($dataset)) {
HomeView::show();
header('Location: /' . $_SESSION['base']);
} elseif ($_SERVER['REQUEST_METHOD'] == 'GET') {
DatasetView::showUpdate();
} else {
$params = $dataset->getParameters();
$params['dataset_name'] = array_key_exists('dataset_name', $_POST) ? $_POST['dataset_name'] : '';
$params['description'] = array_key_exists('description', $_POST) ? $_POST['description'] : '';
$updatedDataset = new Dataset($params);
$updatedDataset->setDatasetId($dataset->getDatasetId());
$returnedDataset = DatasetsDB::updateDataset($updatedDataset);
if ($returnedDataset->getErrorCount() == 0) {
// Show the Dataset view which should display the updated params
DatasetView::show();
header('Location: /' . $_SESSION['base'] . '/dataset/show/' . $dataset->getDatasetId());
} else {
// Carry over the sensors, if any
$updatedDataset->setSensors($dataset->getSensors());
$_SESSION['dataset'] = $updatedDataset;
DatasetView::showUpdate();
}
}
}
示例3: testUpdateDatasetDescription
public function testUpdateDatasetDescription()
{
$myDb = DBMaker::create('sensordatarepotest');
Database::clearDB();
$db = Database::getDB('sensordatarepotest', 'C:\\xampp\\myConfig.ini');
$testDatasetId = 1;
$datasets = DatasetsDB::getDatasetsBy('dataset_id', $testDatasetId);
$dataset = $datasets[0];
$this->assertTrue(empty($dataset->getDescription()), 'Before the update, it should have an empty description');
$params = $dataset->getParameters();
$params['description'] = 'Updated description';
$newDataset = new Dataset($params);
$newDataset->setDatasetId($testDatasetId);
$returnedDataset = DatasetsDB::updateDataset($newDataset);
$this->assertEquals($returnedDataset->getDescription(), $params['description'], 'After the update it should have the name ' . $params['description']);
}