本文整理汇总了PHP中SwatDB::getOptionArray方法的典型用法代码示例。如果您正苦于以下问题:PHP SwatDB::getOptionArray方法的具体用法?PHP SwatDB::getOptionArray怎么用?PHP SwatDB::getOptionArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SwatDB
的用法示例。
在下文中一共展示了SwatDB::getOptionArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadData
protected function loadData()
{
$instance_id = $this->app->getInstanceId();
$where_clause = sprintf('visible = %s and instance %s %s', $this->app->db->quote($this->parent, 'boolean'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
$order_widget = $this->ui->getWidget('order');
$order_widget->addOptionsByArray(SwatDB::getOptionArray($this->app->db, 'PinholeMetaData', 'title', 'id', 'displayorder, title', $where_clause));
$sql = 'select sum(displayorder) from PinholeMetaData where ' . $where_clause;
$sum = SwatDB::queryOne($this->app->db, $sql, 'integer');
$options_list = $this->ui->getWidget('options');
$options_list->value = $sum == 0 ? 'auto' : 'custom';
}
示例2: buildInternal
protected function buildInternal()
{
parent::buildInternal();
$this->buildAuthorWarning();
$instance_id = $this->app->getInstanceId();
$where_clause = sprintf('visible = %s and instance %s %s', $this->app->db->quote(true, 'boolean'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
$author_flydown = $this->ui->getWidget('search_author');
$author_flydown->show_blank = true;
$author_flydown->addOptionsByArray(SwatDB::getOptionArray($this->app->db, 'BlorgAuthor', 'name', 'id', 'name', $where_clause));
}
示例3: saveMetaDataInternal
/**
* Get the meta data from a photo
*
* @param array An array of PinholePhotoMetaDataBinding data objects
* with $shortname as the key of the array.
* @return array An array of PinholeMetaData dataobjects
*/
protected function saveMetaDataInternal($meta_data)
{
$instance_id = $this->image_set->instance === null ? null : $this->image_set->instance->id;
$where_clause = sprintf('PinholeMetaData.instance %s %s', SwatDB::equalityOperator($instance_id), $this->db->quote($instance_id, 'integer'));
$existing_meta_data = SwatDB::getOptionArray($this->db, 'PinholeMetaData', 'shortname', 'id', null, $where_clause);
foreach ($meta_data as $data) {
$shortname = substr($data->shortname, 0, 255);
$title = substr($data->title, 0, 255);
if (mb_check_encoding($data->value, 'UTF-8')) {
$value = $data->value;
} else {
// assume ISO-8859-1
$value = iconv('ISO-8859-1', 'UTF-8', $data->value);
}
$value = substr($value, 0, 255);
if (!in_array($shortname, $existing_meta_data)) {
$meta_data_id = SwatDB::insertRow($this->db, 'PinholeMetaData', array('text:shortname', 'text:title', 'integer:instance'), array('shortname' => $shortname, 'title' => $title, 'instance' => $instance_id), 'id');
} else {
$meta_data_id = array_search($shortname, $existing_meta_data);
}
SwatDB::insertRow($this->db, 'PinholePhotoMetaDataBinding', array('integer:photo', 'integer:meta_data', 'text:value'), array('photo' => $this->id, 'meta_data' => $meta_data_id, 'value' => $value));
}
}