本文整理汇总了PHP中Collection::select方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::select方法的具体用法?PHP Collection::select怎么用?PHP Collection::select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collection
的用法示例。
在下文中一共展示了Collection::select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: selectByCollection
public static function selectByCollection($id)
{
$connection = Flight::dbMain();
try {
$sql = "SELECT * FROM vehicle_collection WHERE collection_id = :collection_id;";
$query = $connection->prepare($sql);
$query->bindParam(':collection_id', $id, PDO::PARAM_INT);
$query->execute();
$rows = $query->fetchAll(PDO::FETCH_ASSOC);
$result = array();
foreach ($rows as $row) {
$vehicleCollection = new VehicleCollection();
$vehicleCollection->Id = (int) $row['id'];
$vehicleCollection->Vehicle = Vehicle::select($row['vehicle_id']);
$vehicleCollection->Collection = Collection::select($row['collection_id']);
array_push($result, $vehicleCollection);
}
return $result;
} catch (PDOException $pdoException) {
throw $pdoException;
} catch (Exception $exception) {
throw $exception;
} finally {
$connection = null;
}
}
示例2: handler_participants
protected function handler_participants(Collection $activities, $fields)
{
$res = XDB::iterator('SELECT id, participant
FROM activities_participants
WHERE id IN {?}', $activities->ids());
$users = new Collection('User');
$part = array();
while ($datas = $res->next()) {
$part[$datas['id']][] = $users->addget($datas['participant']);
}
foreach ($part as $key => $obj) {
$activities->get($key)->participants($obj);
}
$users->select($this->subs['participants']);
}
示例3: smarty_function_origin_picker
function smarty_function_origin_picker($params, &$smarty)
{
$gf = new GroupFilter(new PFC_And(new PFC_Not(new GFC_Namespace(Group::NS_USER)), new GFC_User(S::user(), Rights::admin())), new GFO_Score());
$gs = $gf->get();
if ($params['not_only_admin']) {
$gfo = new GroupFilter(new PFC_And(new GFC_Namespace(array(Group::NS_BINET, Group::NS_FREE)), new GFC_User(S::user(), Rights::restricted())), new GFO_Score());
$gso = $gfo->get()->diff($gs);
$temp = new Collection();
$temp->merge($gs)->merge($gso);
$temp->select(GroupSelect::base());
$smarty->assign('not_admin', $gso);
} else {
$gs = $gf->get()->select(GroupSelect::base());
}
$smarty->assign($params['out'], $gs);
}
示例4: array
function handler_logs_sessions($page)
{
$iter = XDB::iterator('SELECT id, uid, host, ip, forward_ip, forward_host,
browser, suid, flags, start
FROM log_sessions
ORDER BY start DESC
LIMIT 50');
$sessions = array();
$users = new Collection('User');
while ($session = $iter->next()) {
$user = $users->addget($session['uid']);
$sessions[$session['id']] = array('user' => $user, 'host' => $session['host'], 'ip' => uint_to_ip($session['ip']), 'forward_host' => $session['forward_host'], 'forward_ip' => uint_to_ip($session['forward_ip']), 'browser' => $session['browser'], 'suid' => $session['suid'], 'flags' => $session['flags'], 'start' => new FrankizDateTime($session['start']));
}
$users->select(UserSelect::base());
$page->assign('title', "Logs des sessions");
$page->assign('sessions', $sessions);
$page->changeTpl('admin/logs_sessions.tpl');
}
示例5: smarty_function_target_picker
function smarty_function_target_picker($params, &$smarty)
{
// Get user groups
$everybody_groups = S::user()->castes(Rights::everybody())->groups();
// Get Frankiz special groups
$fkz = new Collection('Group');
$fkz->add(array('everybody', 'public'));
$fkz->select(new GroupSelect(array('description')));
// BDE, study and promo groups
$study_groups = $everybody_groups->filter('ns', Group::NS_BDE);
$study_groups->merge($everybody_groups->filter('ns', Group::NS_PROMO));
$study_groups->merge($everybody_groups->filter('ns', Group::NS_STUDY));
// Get all groups user is admin, without the user one
$gs = S::user()->castes(Rights::admin())->groups();
$gs->diff($fkz);
$gs->filter(function ($g) {
return $g->ns() != Group::NS_USER;
});
if ($params['even_only_friend']) {
$gfo = new GroupFilter(new PFC_And(new GFC_Namespace(array(Group::NS_BINET, Group::NS_FREE)), new GFC_User(S::user(), Rights::everybody())), new GFO_Score());
$gso = $gfo->get()->diff($gs)->diff($fkz);
$temp = new Collection();
$temp->merge($gs)->merge($gso);
$temp->select(GroupSelect::base());
$smarty->assign('only_friend', $gso);
$temp = new Collection();
$temp->merge($gs)->merge($fkz)->merge($gso);
$temp->select(GroupSelect::base());
} else {
$temp = new Collection();
$temp->merge($gs)->merge($fkz);
$temp->select(GroupSelect::base());
}
$smarty->assign($params['user_groups'], $gs);
$smarty->assign($params['fkz_groups'], $fkz);
$smarty->assign($params['study_groups'], $study_groups);
$smarty->assign($params['own_group'], S::user()->group());
}
示例6: getDoctorsListCount
public function getDoctorsListCount($latitude = 0, $longitude = 0, $query = array())
{
$this->data = DB::table('doctors');
$this->data->leftJoin('doctors_details AS dhospital', 'doctors.id', '=', 'dhospital.doctor_id');
$this->data->leftJoin('listing_hospitals', 'dhospital.detail_id', '=', 'listing_hospitals.id');
$this->data->leftJoin('doctors_details AS dhmo', 'doctors.id', '=', 'dhmo.doctor_id');
$this->data->leftJoin('listing_hmo', 'dhmo.detail_id', '=', 'listing_hmo.id');
$this->data->leftJoin('doctors_specialization', 'doctors.id', '=', 'doctors_specialization.doctor_id');
$this->data->leftJoin('location_cities', 'listing_hospitals.city', '=', 'location_cities.id');
$this->data->leftJoin('location_provinces', 'listing_hospitals.province', '=', 'location_provinces.id');
$this->data->select(DB::raw("doctors.*, dhospital.detail_id as hospital_id, listing_hospitals.listing_title as hospital_title, listing_hospitals.latitude, listing_hospitals.longitude, listing_hospitals.street, location_cities.city_name, location_provinces.province_name, dhmo.detail_id as hmo_id, listing_hmo.listing_title as hmo_title, doctors_specialization.specialization_id, (6371 * acos (cos ( radians(?) ) * cos( radians( listing_hospitals.latitude ) ) * cos( radians( listing_hospitals.longitude ) - radians(?) ) + sin ( radians(?) ) * sin( radians( listing_hospitals.latitude ) ))) AS distance"))->setBindings([$latitude, $longitude, $latitude]);
$this->data->where('dhospital.detail_type', '=', 1);
$this->data->where('dhmo.detail_type', '=', 4);
if (isset($query['specializations'])) {
$this->data->whereIn('doctors_specialization.specialization_id', $query['specializations']);
}
if (isset($query['locations'])) {
$this->data->whereIn('listing_hospitals.city', $query['locations']);
}
$this->data->groupBy('doctors.id');
// }
return $this->data->get();
}
示例7: all
public static function all()
{
$res = XDB::iterator('SELECT id, date, question, answer1, answer2, count1, count2, writer
FROM qdj
WHERE date!="0000-00-00" AND date<NOW()
ORDER BY date DESC');
$qdjs = new Collection('QDJ');
$users = new Collection('User');
while ($datas = $res->next()) {
$datas['writer'] = $users->addget($datas['writer']);
$datas['date'] = new FrankizDateTime($datas['date']);
$qdjs->addget($datas['id'])->fillFromArray($datas);
}
$users->select(UserSelect::base());
return $qdjs;
}
示例8: helper_collection
/**
* Select a collection from the database
*
* @param Collection $metas The objects to select
* @param string $field collection field
*/
protected function helper_collection(Collection $metas, $field)
{
// Retrieve link attributes
list($l_className, $table, $l_id, $id) = $this->schema->collectionType($field);
$_metas = array();
foreach ($metas as $meta) {
$_metas[$meta->id()] = new Collection($l_className);
}
// Get collection ids
$iter = XDB::iterRow("SELECT {$id}, {$l_id}\n FROM {$table}\n WHERE {$id} IN {?}", $metas->ids());
$linkeds = new Collection($l_className);
while (list($id, $l_id) = $iter->next()) {
$linked = $linkeds->addget($l_id);
$_metas[$id]->add($linked);
}
// Update metas
foreach ($metas as $meta) {
$meta->fillFromArray(array($field => $_metas[$meta->id()]));
}
if (!empty($this->subs[$field])) {
$linkeds->select($this->subs[$field]);
}
}
示例9: handler_questions
protected function handler_questions(Collection $surveys, array $fields)
{
$_surveys = array();
foreach ($surveys as $s) {
$_surveys[$s->id()] = new Collection('SurveyQuestion');
$_surveys[$s->id()]->order('rank', false);
}
$iter = XDB::iterRow("SELECT qid, survey, type\n FROM surveys_questions\n WHERE survey IN {?}", $surveys->ids());
$questions = new Collection('SurveyQuestion');
while (list($qid, $sid, $type) = $iter->next()) {
$className = 'SurveyQuestion' . $type;
$question = new $className($qid);
$questions->add($question);
$_surveys[$sid]->add($question);
}
foreach ($surveys as $s) {
$s->fillFromArray(array('questions' => $_surveys[$s->id()]));
}
if (!empty($questions) && !empty($this->subs['questions'])) {
$questions->select($this->subs['questions']);
}
}
示例10: getDetails
public function getDetails($title_id)
{
if (!$title_id) {
Redirect::to("/");
}
$title_db = Title::with(array("gallery_image", "video", "genre", "rating", "producttype"))->find($title_id);
if (!is_object($title_db)) {
return Redirect::to("/");
}
$title_db->favorite = Favorite::where("title_id", "=", $title_id)->where("user_id", "=", Auth::user()->id)->get();
$title = $title_db->toArray();
//dd($title);
// Get all Image paths for this title
// ---------------------
if (count($title['gallery_image']) > 0) {
$gallery_image_path = Config::get('nbc.imageRootImagePath') . $title['gallery_image'][0]['file'];
} else {
$gallery_image_path = "/images/x-image-placeholder.png";
}
$fullpath_to_gallery_image = $gallery_image_path;
// Get all Video paths for this title
// ---------------------
$video_file_path_array = array();
if (is_array($title['video']) && count($title['video']) > 0) {
foreach ($title['video'] as $video) {
$videofile_path = $this->getTitleVideoPath($title['final_title']);
$videofile_localpath = Config::get('nbc.imageRootLocalVideoPath');
if (!$videofile_localpath && strpos($videofile_path, '://') === false) {
$videofile_localpath = $videofile_path;
}
$fileExists = false;
// Get file headers to determine 404
if ($videofile_localpath && file_exists($_SERVER['DOCUMENT_ROOT'] . $videofile_localpath . $video['file'])) {
$fileExists = true;
$videofile_path = $videofile_localpath;
}
if (!$fileExists && $videofile_localpath != $videofile_path && curl_htmlcode($videofile_path . $video['file']) != 404) {
$fileExists = true;
}
if ($fileExists) {
$video_file_path_array[] = array("filepath" => $videofile_path . $video['file'], "type" => $this->getVideoType($video['file']), "id" => $video['id']);
}
}
}
$cast_array = explode(",", $title['actors']);
$directors_array = explode(",", $title['directors']);
$producers_array = explode(",", $title['producers']);
$writers_array = explode(",", $title['writers']);
$awards_array = explode(",", $title['awards']);
$genres = array();
if (is_array($title["genre"])) {
foreach ($title["genre"] as $genre) {
$genres[] = $genre['name'];
}
}
if ($title['rating']['name'] == "") {
$rating = "none";
} else {
$rating = $title['rating']['name'];
}
if ($title['color'] == "1") {
$color = "color";
} else {
$color = "black & white";
}
/* if ( strlen( $title['synopsis'] ) > 720 ) {
$partialsynopsis = str_limit($title['synopsis'],720);
$enable_more = 1;
} else {
//synop = t ( synop );
$enable_more = 0;
$partialsynopsis = "";
}*/
$user_id = Auth::user()->id;
$collections = Collection::select('id', 'name')->where("user_id", "=", $user_id)->where('status_id', '<>', '6')->orderBy('name')->get()->toArray();
$collection_dropdown = array();
foreach ($collections as $collection) {
$shortened_coll_name = str_limit($collection['name'], 25);
$collection_dropdown[$collection['id']] = $shortened_coll_name;
}
$default_collection_id = $this->getUserLastCollectionUsed();
if (isset($default_collection_id) and $default_collection_id) {
$first_collection_id = $default_collection_id;
} else {
reset($collection_dropdown);
$first_collection_id = key($collection_dropdown);
}
// Add insert to Report table, for reporting
$user_id = Auth::user()->id;
$user = User::find($user_id);
$report = Report::create(array('date' => time(), 'action_type' => 1, 'action_user_id' => $user_id, 'object_id' => $title_id, 'report_type' => 1, 'aux_object' => $user['region_id']));
$report = Report::create(array('date' => time(), 'action_type' => 1, 'action_user_id' => $user_id, 'object_id' => $title_id, 'report_type' => 3, 'aux_object' => $user['region_id']));
// Unpack serialized runtimes
if ($title['runtime_serialized'] != '') {
$title['runtimes'] = unserialize($title['runtime_serialized']);
} else {
$title['runtimes'][0] = array('episode_cnt' => $title['episode_cnt'], 'runtime_minutes_cnt' => $title['runtime_minutes_cnt']);
}
$data = array("title" => $title, "mode" => "preview_title", "actors" => $cast_array, "directors" => $directors_array, "producers" => $producers_array, "writers" => $writers_array, "awards" => $awards_array, "genres" => $genres, "rating" => $rating, "color" => $color, 'first_collection_id' => $first_collection_id, 'collections' => $collection_dropdown, 'gallery_image_path' => $fullpath_to_gallery_image, 'video_file_path_array' => $video_file_path_array);
//dd($enable_more);
//.........这里部分代码省略.........
示例11: implode
function handler_admin($page, $id = null, $action = null)
{
$page->assign('title', "Administration de l'authentification externe");
$page->assign('remoterights_available', implode(',', Remote::availableRights()));
// Find remote
$remote = null;
if ($id == 'new') {
$remote = new Remote();
$remote->insert();
} elseif (Remote::isId($id)) {
$remote = new Remote($id);
// Delete a remote
if ($action == 'delete') {
$remote->delete();
$remote = null;
}
}
if (!empty($remote)) {
$remote->select(RemoteSelect::groups());
if (Env::has('change_remote')) {
$remote->site(Env::t('site'));
$remote->label(Env::t('label'));
$remote->privkey(Env::t('privkey'));
$rights = explode(',', Env::t('rights'));
foreach ($rights as $k => $v) {
$rights[$k] = strtolower(trim($v));
}
$rights = array_intersect($rights, Remote::availableRights());
$remote->rights(new PlFlagSet(implode(',', $rights)));
$groups = new Collection('Group');
$groups_fields = array('binets', 'frees');
foreach ($groups_fields as $field) {
foreach (explode(';', Env::t($field)) as $gid) {
$gid = trim($gid);
if ($gid) {
$groups->add(new Group($gid));
}
}
}
$groups->select(GroupSelect::base());
$remote->groups($groups);
}
$page->assign('remote', $remote);
$page->changeTpl('remote/admin.tpl');
} else {
$remotes = Remote::selectAll(RemoteSelect::groups());
$page->assign('remotes', $remotes);
$page->changeTpl('remote/list.tpl');
}
}
示例12: batchSelect
public static function batchSelect(array $wikis, $options = null)
{
if (empty($wikis)) {
return;
}
$bits = self::optionsToBits($options);
$wikis = array_combine(self::toIds($wikis), $wikis);
$joins = array();
$cols = array();
if ($bits & self::SELECT_BASE) {
$cols['w'] = array('name', 'comments');
}
if ($bits & self::SELECT_COUNT || $bits & self::SELECT_VERSION) {
$cols[-1] = array('COUNT(wv.version) AS count');
$joins['wv'] = PlSqlJoin::left('wiki_version', '$ME.wid = w.wid');
}
if (!empty($cols)) {
$iter = XDB::iterator('SELECT w.wid AS id, ' . self::arrayToSqlCols($cols) . '
FROM wiki AS w
' . PlSqlJoin::formatJoins($joins, array()) . '
WHERE w.wid IN {?}
GROUP BY w.wid', array_keys($wikis));
while ($datas = $iter->next()) {
$wikis[$datas['id']]->fillFromArray($datas);
}
}
// Load last version
if ($bits & self::SELECT_VERSION) {
if (!isset($options[self::SELECT_VERSION])) {
$opts = array('versions' => array('last'));
} else {
$opts = $options[self::SELECT_VERSION];
}
$conds = array();
foreach ($wikis as $w) {
if ($w->versions == null) {
$w->versions = array();
}
$versions = array();
if (in_array('last', $opts['versions'])) {
$versions[] = $w->count();
}
foreach ($opts['versions'] as $version) {
if ($version != 'last') {
$versions[] = $version;
}
}
if (!empty($versions)) {
$conds[] = XDB::format('( wid = {?} AND version IN {?} )', $w->id(), $versions);
}
}
$iter = XDB::iterator('SELECT wid AS id, version, wrote, writer, content
FROM wiki_version
WHERE ' . implode(' OR ', $conds));
$writers = new Collection('User');
while ($datas = $iter->next()) {
$writer = $writers->addget($datas['writer']);
$wikis[$datas['id']]->versions[$datas['version']] = array('wrote' => $datas['wrote'], 'writer' => $writer, 'content' => $datas['content']);
}
if (isset($opts['options'])) {
$writers->select($opts['options']);
}
}
}
示例13: handler_cuvisibility
/**
* Select a GID which identifies the visibility of a caste-user assocation
*/
protected function handler_cuvisibility(Collection $users, $fields)
{
$_users = array();
foreach ($users as $u) {
$_users[$u->id()] = array();
}
$viscoll = new Collection('Group');
$iter = XDB::iterRow('SELECT uid, cid, visibility
FROM castes_users
WHERE uid IN {?}', $users->ids());
while (list($uid, $cid, $vis) = $iter->next()) {
$_users[$uid][$cid] = $vis;
if ($vis != 0) {
$viscoll->add($vis);
}
}
$viscoll->select(GroupSelect::base());
foreach ($users as $u) {
$cuarray = array_map(function ($gid) use($viscoll) {
return $gid == 0 ? null : $viscoll->get($gid);
}, $_users[$u->id()]);
$u->fillFromArray(array('cuvisibility' => $cuarray));
}
}
示例14: handler_castes
protected function handler_castes(Collection $groups, $fields)
{
$_groups = array();
foreach ($groups as $g) {
$_groups[$g->id()] = new Collection('Caste');
}
$iter = XDB::iterRow('SELECT cid, `group`, rights
FROM castes
WHERE `group` IN {?}', $groups->ids());
$castes = new Collection('Caste');
while (list($cid, $group, $rights) = $iter->next()) {
$caste = new Caste(array('id' => $cid, 'group' => $groups->get($group), 'rights' => new Rights($rights)));
$castes->add($caste);
$_groups[$group]->add($caste);
}
foreach ($groups as $g) {
$g->fillFromArray(array('castes' => $_groups[$g->id()]));
}
if (!empty($castes) && !empty($this->subs['castes'])) {
$castes->select($this->subs['castes']);
}
}
示例15: loadFeaturedLightbox
public function loadFeaturedLightbox()
{
$collections = Collection::select('id', 'name as collection_name', 'short_name as collection_short_name', 'order_no')->rightJoin('collections_images', 'collections_images.collection_id', '=', 'collections.id')->orderBy('order_no', 'desc')->groupBy('collections.id')->distinct()->take(10)->get()->toArray();
foreach ($collections as $key => $value) {
$image = CollectionImage::where('collection_id', '=', $value['id'])->where('collections_images.type', '=', 'main')->leftJoin('images', 'collections_images.image_id', '=', 'images.id')->leftJoin('image_details', 'image_details.image_id', '=', 'collections_images.image_id')->groupBy('collection_id')->get()->toArray();
if (count($image) == 0) {
$image = CollectionImage::where('collection_id', '=', $value['id'])->leftJoin('images', 'collections_images.image_id', '=', 'images.id')->leftJoin('image_details', 'image_details.image_id', '=', 'collections_images.image_id')->groupBy('collection_id')->get()->toArray();
}
$collections[$key]['image'] = count($image) > 0 ? $image[0] : array();
}
$arrFeaturedLightbox = array();
if (count($collections)) {
$i = 0;
foreach ($collections as $value) {
$arrFeaturedLightbox[$i]['collection_id'] = $value['id'];
$arrFeaturedLightbox[$i]['collection_short_name'] = $value['collection_short_name'];
$arrFeaturedLightbox[$i]['collection_name'] = $value['collection_name'];
$arrFeaturedLightbox[$i]['path'] = '/pic/thumb/' . $value['image']['short_name'] . '-' . $value['image']['image_id'] . '.jpg';
$arrFeaturedLightbox[$i]['width'] = $value['image']['width'];
$arrFeaturedLightbox[$i]['height'] = $value['image']['height'];
$i++;
}
}
if (Request::ajax()) {
$html = View::make('frontend.lightbox.featured-lightboxs')->with('arrFeaturedLightbox', $arrFeaturedLightbox)->render();
$arrReturn = ['status' => 'ok', 'message' => '', 'html' => $html];
$response = Response::json($arrReturn);
$response->header('Content-Type', 'application/json');
return $response;
}
return View::make('frontend.types.featured-collections')->with('arrFeaturedCollection', $arrFeaturedLightbox)->render();
}