当前位置: 首页>>代码示例>>PHP>>正文


PHP select函数代码示例

本文整理汇总了PHP中select函数的典型用法代码示例。如果您正苦于以下问题:PHP select函数的具体用法?PHP select怎么用?PHP select使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了select函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update

    protected static function update()
    {
        global $current_user;
        $id = $_POST['id'];
        $url = isset($_POST['url']) ? $_POST['url'] : null;
        $name = isset($_POST['name']) ? $_POST['name'] : null;
        $tags = isset($_POST['tags']) ? explode(',', $_POST['tags']) : null;
        if ($url) {
            insert('UPDATE bookmark SET url="' . $url . '" WHERE id=' . $id);
        }
        if ($name) {
            insert('UPDATE bookmark SET name="' . $name . '" WHERE id=' . $id);
        }
        if ($tags) {
            $db_tags = select('SELECT id FROM tag
								INNER JOIN classification
								ON tag.id=classification.tag_id
								WHERE user_id=' . $current_user['id'] . ' AND bookmark_id=' . $id);
            foreach ($db_tags as $tag) {
                $index = array_search($tag['id'], $tags);
                if ($index) {
                    unset($tags[$index]);
                } else {
                    // $tag is in the db but not in tags so delete it from the db
                    insert('DELETE FROM classification
							WHERE bookmark_id=' . $id . ' AND tag_id=' . $tag['id']);
                }
            }
            foreach ($tags as $tag) {
                insert('INSERT INTO classification (bookmark_id,tag_id)
						VALUES (' . $id . ',' . $tag . ')');
            }
        }
    }
开发者ID:hillam,项目名称:bookmarks,代码行数:34,代码来源:bookmarks.php

示例2: questionsAvailable

function questionsAvailable($courseId)
{
    $options = [];
    $diff1 = [];
    $diff2 = [];
    $diff3 = [];
    $counter = [];
    $questions = select("SELECT id, difficulty FROM questions WHERE category_id ='{$courseId}'");
    foreach ($questions as $question) {
        $options[] = select("SELECT id FROM options WHERE question_id =" . $question['id']);
        if ($question['difficulty'] == 1) {
            $diff1[] = $question['difficulty'];
        }
        if ($question['difficulty'] == 2) {
            $diff2[] = $question['difficulty'];
        }
        if ($question['difficulty'] == 3) {
            $diff3[] = $question['difficulty'];
        }
    }
    $numQuestions = count($questions);
    $numOptions = count($options) * 4;
    $counter[] = count($questions);
    $counter[] = count($options) * 4;
    $counter[] = count($diff1);
    $counter[] = count($diff2);
    $counter[] = count($diff3);
    return array($numQuestions, $numOptions);
    //return $counter;
}
开发者ID:brightantwiboasiako,项目名称:tratech2016,代码行数:30,代码来源:available_questions.php

示例3: changePassword

function changePassword($userId, $prevPass, $newPass1, $newPass2)
{
    $msg = [];
    if (empty($prevPass) || empty($newPass1) || empty($newPass2)) {
        $msg[] = "All fields are required";
    } else {
        // retrieve user previous password
        $password = select("SELECT password FROM users WHERE id =" . $userId)[0];
        if ($password['password'] != md5($prevPass)) {
            $msg[] = " Incorrect current password";
        }
        if ($newPass1 == $newPass2) {
            $passlength = strlen($newPass1);
            if (!($passlength >= 5 && $passlength <= 20)) {
                $msg[] = "New password characters out of required range( 5 - 20 )";
            }
        } else {
            $msg[] = "New passwords do not match";
        }
        if (count($msg) == 0) {
            // no errors
            $newPass1 = escape($newPass1);
            $password_hash = md5($newPass1);
            if (mysql_query("UPDATE users SET password = '" . $password_hash . "' WHERE id ='" . $userId . "'")) {
                $msg[] = "Password has been successfully updated";
            } else {
                $msg[] = "Unable to save changes";
            }
        }
    }
    return $msg;
}
开发者ID:brightantwiboasiako,项目名称:tratech2016,代码行数:32,代码来源:user.php

示例4: process

 public function process()
 {
     AddRatingFieldToSchema::process();
     $main = Product::getInstanceByID($this->request->get('id'), true);
     if ($main->parent->get()) {
         $main->parent->get()->load();
         $var = $main->toArray();
         $var['custom'] = $main->custom->get();
         $this->request->set('variation', $var);
         $this->request->set('activeVariationID', $this->request->get('id'));
         $main = $main->parent->get();
         $this->request->set('id', $main->getID());
         $productArray = $main->toArray();
         $handle = empty($productArray['URL']) ? $productArray['name_lang'] : $productArray['URL'];
         $this->request->set('producthandle', $handle);
     }
     ActiveRecord::clearPool();
     $variations = $main->getRelatedRecordSet('Product', select());
     $handle = $main->URL->get() ? $main->URL->get() : $main->getValueByLang('name', 'en');
     foreach ($variations as $variation) {
         $variation->setValueByLang('name', 'en', $main->getValueByLang('name', 'en') . ' ' . $variation->sku->get());
         $variation->URL->set($handle . ' ' . $variation->sku->get());
         $variation->parent->set(null);
     }
     $variations->toArray();
 }
开发者ID:saiber,项目名称:www,代码行数:26,代码来源:PreloadVariations.php

示例5: basicAPI

function basicAPI($parameter)
{
    header('Content-Type: application/json');
    require '../php/config.php';
    if (isset($_GET['src'])) {
        $records = array();
        switch ($_GET['src']) {
            case 'chart':
                $records = select($mysqli, "SELECT {$parameter} AS name, count(*) AS data FROM toscana GROUP BY {$parameter}");
                for ($i = 0; $i < count($records); $i++) {
                    $records[$i]['data'] = array(intval($records[$i]['data']));
                }
                break;
            case 'map':
                $raw_records = select($mysqli, "SELECT {$parameter} AS type, nome AS name, indirizzo AS address, lt, lg FROM toscana ORDER BY RAND() LIMIT 1000");
                for ($i = 0; $i < count($raw_records); $i++) {
                    $records[$raw_records[$i]['type']][] = $raw_records[$i];
                }
                break;
        }
        return json_encode($records);
    } else {
        return json_encode(array('status' => 'error', 'details' => 'no src provided'));
    }
}
开发者ID:aquablue8200,项目名称:RedMeat,代码行数:25,代码来源:MyAPI.php

示例6: reason

function reason()
{
    extract($_REQUEST);
    if (!isset($supid) || !is_numeric($supid)) {
        return select();
    }
    $sql = "SELECT id, date, reason_id, amount FROM cubit.recon_balance_ct\n\t\t\tWHERE supid='{$supid}'\n\t\t\tORDER BY id DESC";
    $balance_rslt = db_exec($sql) or errDie("Unable to retrieve balances.");
    $sql = "SELECT id, reason FROM cubit.recon_reasons ORDER BY reason ASC";
    $reason_rslt = db_exec($sql) or errDie("Unable to retrieve reasons.");
    $balance_out = "";
    while (list($bal_id, $date, $reason_id, $amount) = pg_fetch_array($balance_rslt)) {
        $reasons_sel = "\n\t\t<select name='oreason_id'>\n\t\t\t<option value='0'>[None]</option>";
        pg_result_seek($reason_rslt, 0);
        while (list($id, $reason) = pg_fetch_array($reason_rslt)) {
            if ($reason_id == $id) {
                $sel = "selected='selected'";
            } else {
                $sel = "";
            }
            $reasons_sel .= "<option value='{$id}' {$sel}>{$reason}</option>";
        }
        $reasons_sel .= "</select>";
        $balance_out .= "\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td>{$date}</td>\n\t\t\t<td>{$reasons_sel}</td>\n\t\t\t<td>\n\t\t\t\t<input type='text' name='amount[{$bal_id}]' value='{$amount}' size='8' />\n\t\t\t</td>\n\t\t\t<td><input type='checkbox' name='remove[{$bal_id}]' value='{$bal_id}' /></td>\n\t\t</tr>";
    }
    pg_result_seek($reason_rslt, 0);
    $reason_sel = "\n\t<select name='nreason_id'>\n\t\t<option value='0'>[None]</option>";
    while (list($id, $reason) = pg_fetch_array($reason_rslt)) {
        $reason_sel .= "<option value='{$id}'>{$reason}</option>";
    }
    $reason_sel .= "</select>";
    $OUTPUT = "\n\t<center>\n\t<h3>Add Balance According to Creditor</h3>\n\t<form method='post' action='" . SELF . "'>\n\t<input type='hidden' name='key' value='reason_update' />\n\t<input type='hidden' name='supid' value='{$supid}' />\n\t<table " . TMPL_tblDflts . ">\n\t\t<tr>\n\t\t\t<th>Date</th>\n\t\t\t<th>Reason</th>\n\t\t\t<th>Amount</th>\n\t\t\t<th>Remove</th>\n\t\t</tr>\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td>" . date("Y-m-d") . "</td>\n\t\t\t<td>{$reason_sel}</td>\n\t\t\t<td><input type='text' name='namount' size='8' /></td>\n\t\t\t<td>&nbsp;</td>\n\t\t</tr>\n\t\t{$balance_out}\n\t</table>\n\t<input type='submit' value='Update' />\n\t</form>\n\t<table " . TMPL_tblDflts . ">\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td>\n\t\t\t\t<a href='recon_statement_ct.php?key=display&supid={$supid}'\n\t\t\t\tstyle='font-size: 1.3em'>\n\t\t\t\t\tReturn to Statement\n\t\t\t\t</a>\n\t\t\t</td>\n\t\t</tr>\n\t</center>";
    return $OUTPUT;
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:34,代码来源:recon_balance_ct.php

示例7: cls_games

 function cls_games()
 {
     global $reglament, $tournament, $tour, $auth;
     if (!$tournament) {
         $this->tournament = 1;
     } else {
         $this->tournament = $tournament;
     }
     if (!$reglament) {
         $this->reglament = $this->maxreglament();
     } else {
         $this->reglament = $reglament;
     }
     //$q=select("select ReglamentID,TournamentID from ut_reglaments where (ReglamentID='$this->reglament') order by Tour2 desc");
     //$this->reglament=$q[ReglamentID];
     $q = select("select DivisionID from ut_teams where TeamID='{$auth->team}'");
     $this->division = $q[0];
     $q = select("select SeasonID from ut_seasons where StartDate>0 order by Num desc limit 0,1");
     $this->season = $q[0];
     if (!$tour) {
         $this->tour = $this->maxtour();
     } else {
         $this->tour = $tour;
     }
 }
开发者ID:dapfru,项目名称:gladiators,代码行数:25,代码来源:cls_games.php

示例8: insert_data

function insert_data($db, $message)
{
    #gather variables we'll need.
    $safe_title = $db->real_escape_string($message["title"]);
    $safe_ingredients = $db->real_escape_string($message["ingredients"]);
    $safe_instructions = $db->real_escape_string($message["instructions"]);
    $cat_id = "nothing";
    #determine which cat_id(table column)to assign to the new recipe row.
    switch ($message["category"]) {
        case "meat":
            $cat_id = 4;
            break;
        case "veggies":
            $cat_id = 5;
            break;
        case "bread":
            $cat_id = 6;
            break;
        default:
            $db->close();
            die("Invalid category value.");
            break;
    }
    #now let's use a prepared statement to use dynamic data in an INSERT INTO query.
    $sql = $db->prepare("INSERT INTO recipestbl VALUES(NULL,?,?,?,?)");
    $sql->bind_param("sssi", $safe_title, $safe_ingredients, $safe_instructions, $cat_id);
    $sql->execute();
    $recent_insert = $db->insert_id;
    select($db, $recent_insert);
    $sql->free_result();
}
开发者ID:myNameisNotThis,项目名称:recipeCollection,代码行数:31,代码来源:mysql.php

示例9: indexAction

 protected function indexAction()
 {
     $this->view->title = 'Тестовый раздел';
     $this->view->headers = array(array('title' => 'Тестовый раздел'));
     $testModel = new Admin_Model_Test();
     /// Example mfa - выбор списка записей элементов
     $this->view->mfa = $testModel->mfa(select()->where(array('test_field' => '1test_f')));
     /// Example mfo - выбор одного элемента из базы записей, необходимо обязательно указать название поля в селекте
     $this->view->mfo = $testModel->mfo(select('test_id')->where(array('test_field2' => '3test_f2')));
     /// Example mfs - выбор одного элемента из базы записей, необходимо обязательно указать название поля в селекте
     $this->view->mfs = $testModel->mfs(select('test_field')->where(array('test_field2' => '4test_f2')));
     /// Example mfm - выборка fetchMap
     /** @param $keyField - поле ключа 
      *  @param $valueField - поле значения
      *  @param $sql - условие выборки 
      *  @param $count - количество
      *  @param $keyPrintFormat - формат записи ключа
      *  @return array['$keyField'] = $valueField    
      */
     $this->view->mfm = $testModel->mfm(select()->where());
     /// выборка количества записей c условием
     $this->view->count = $testModel->count(select()->where());
     /// Example save - сохранение или обновление записи
     // $testModel->save( select()->where() );
     $this->render('test');
 }
开发者ID:CrazyBobik,项目名称:allotaxi.test,代码行数:26,代码来源:test.php

示例10: first_schedule

function first_schedule($tournament, $members, $numplayers)
{
    global $stage, $id, $fights, $num;
    $id = $tournament;
    $q = select("select * from ft_tournaments where TournamentID='{$id}'");
    if ($q[StatusID] != 0) {
        return 0;
    }
    if ($members + 1 != $numplayers) {
        return 0;
    }
    $r = select("select * from ft_stages where TournamentTypeID={$q['TournamentTypeID']}  and Tour1=1 limit 0,1");
    $res2 = runsql("select * from ft_tournament_members where TournamentID='{$id}' order by rand()");
    for ($k = 1; $k <= $numplayers; $k++) {
        $r2 = mysql_fetch_array($res2);
        $users[$k] = $r2[UserID];
    }
    if ($r[TypeID] == 0) {
        for ($k = 1; $k <= $numplayers; $k++) {
            runsql("update ft_tmp_agreements set UserID1='{$users[$k]}',\nLogin1=(select concat(if(GuildID>0 and GuildStatusID=1,concat('<img src=/images/gd_guilds/small/',GuildID,'.jpg border=0 align=absmiddle>','</a> '),''),'<a href=/users/',UserID,'/>',Login,'</a>') from ut_users where UserID='{$users[$k]}') \n where TournamentID='{$id}' and Tour=1 and Pair1='{$k}'");
            runsql("update ft_tmp_agreements set UserID2='{$users[$k]}',\nLogin2=(select concat(if(GuildID>0 and GuildStatusID=1,concat('<img src=/images/gd_guilds/small/',GuildID,'.jpg border=0 align=absmiddle>','</a> '),''),'<a href=/users/',UserID,'/>',Login,'</a>') from ut_users where UserID='{$users[$k]}') \n where TournamentID='{$id}' and Tour=1 and Pair2='{$k}'");
        }
    } else {
        for ($k = 1; $k <= $numplayers; $k++) {
            runsql("update ft_tmp_agreements set UserID1='{$users[$k]}',\nLogin1=(select concat(if(GuildID>0 and GuildStatusID=1,concat('<img src=/images/gd_guilds/small/',GuildID,'.jpg border=0 align=absmiddle>','</a> '),''),'<a href=/users/',UserID,'/>',Login,'</a>') from ut_users where UserID='{$users[$k]}') \n where TournamentID='{$id}' and Stage=1 and Pair1='{$k}'");
            runsql("update ft_tmp_agreements set UserID2='{$users[$k]}',\nLogin2=(select concat(if(GuildID>0 and GuildStatusID=1,concat('<img src=/images/gd_guilds/small/',GuildID,'.jpg border=0 align=absmiddle>','</a> '),''),'<a href=/users/',UserID,'/>',Login,'</a>') from ut_users where UserID='{$users[$k]}') \n where TournamentID='{$id}' and Stage=1 and Pair2='{$k}'");
            runsql("update ft_groups set UserID='{$users[$k]}',Login=(select concat(if(GuildID>0 and GuildStatusID=1,concat('<a href=/guilds/',GuildID,'><img src=/images/gd_guilds/small/',GuildID,'.jpg border=0 align=absmiddle>','</a> '),''),'<a href=/users/',UserID,'/>',Login,'</a>') from ut_users where UserID='{$users[$k]}') where TournamentID='{$id}' and Stage=1 and Pair='{$k}'");
        }
    }
    runsql("delete from ft_agreements where TournamentID='{$id}'");
    runsql("insert into ft_agreements\n(UserID1,UserID2,TypeID,ExtraGlad,LimitGlad,LimitSkl,Timeout,TournamentID,Stage,Tour,Fight,Pair,NumFights,StageTypeID,Approved,StatusID,Date,Login1,Login2) \n(select UserID1,UserID2,TypeID,ExtraGlad,LimitGlad,LimitSkl,Timeout,TournamentID ,Stage,Tour,Fight,Pair,NumFights,StageTypeID, 1,2,unix_timestamp(),Login1,Login2\nfrom ft_tmp_agreements where TournamentID='{$id}' and Tour=1 and Fight=1)");
    runsql("update ft_tournaments set StatusID=1 where TournamentID='{$id}'");
}
开发者ID:dapfru,项目名称:gladiators,代码行数:33,代码来源:tournaments.php

示例11: process

 public function process()
 {
     if (!$this->response instanceof ActionResponse) {
         return;
     }
     $products = $this->response->get('products');
     $ids = array();
     foreach ($products as $key => $product) {
         $ids[$product['ID']] = !empty($product['parentID']) ? $product['parentID'] : $product['ID'];
     }
     if (!$ids) {
         return;
     }
     $f = select(in(f('ProductImage.productID'), array_values($ids)), new LikeCond(f('ProductImage.title'), '%Virtual Mirror%'));
     $hasMirror = array();
     foreach (ActiveRecordModel::getRecordSetArray('ProductImage', $f) as $mirror) {
         $hasMirror[$mirror['productID']] = true;
     }
     foreach ($ids as $realID => $parentID) {
         if (!empty($hasMirror[$parentID])) {
             $hasMirror[$realID] = true;
         }
     }
     foreach ($products as $key => $product) {
         if ($hasMirror[$product['ID']]) {
             $products[$key]['hasMirror'] = true;
         }
     }
     $this->response->set('hasMirror', $hasMirror);
     $this->response->set('products', $products);
 }
开发者ID:saiber,项目名称:www,代码行数:31,代码来源:LoadMirror.php

示例12: edit

 public function edit()
 {
     $newsletter = ActiveRecordModel::getInstanceById('NewsletterMessage', $this->request->get('id'), ActiveRecordModel::LOAD_DATA);
     $form = $this->getForm();
     $form->setData($newsletter->toArray());
     $form->set('users', 1);
     $form->set('subscribers', 1);
     $response = new ActionResponse('form', $form);
     $groupsArray = array_merge(ActiveRecord::getRecordSetArray('UserGroup', select()), array(array('ID' => null, 'name' => $this->translate('Customers'))));
     usort($groupsArray, array($this, 'sortGroups'));
     $response->set('groupsArray', $groupsArray);
     $newsletterArray = $newsletter->toArray();
     $text = strlen($newsletterArray['text']);
     $html = strlen($newsletterArray['html']);
     if ($text && $html) {
         $newsletterArray['format'] = self::FORMAT_HTML_TEXT;
     } else {
         if ($text) {
             $newsletterArray['format'] = self::FORMAT_TEXT;
         } else {
             if ($html) {
                 $newsletterArray['format'] = self::FORMAT_HTML;
             }
         }
     }
     $response->set('newsletter', $newsletterArray);
     $response->set('sentCount', $newsletter->getSentCount());
     $response->set('recipientCount', $this->getRecipientCount($form->getData()));
     return $response;
 }
开发者ID:saiber,项目名称:livecart,代码行数:30,代码来源:NewsletterController.php

示例13: GetImage

 function GetImage($id)
 {
     $this->load->database();
     $this->db - select('id', $id);
     $result = $this->db->get('cbir_index')->result_array();
     return $result;
 }
开发者ID:Kaelcao,项目名称:cbir,代码行数:7,代码来源:Image.php

示例14: confirm

function confirm(&$frm)
{
    if ($frm->validate("confirm")) {
        return select($frm);
    }
    $frm->setkey("write");
    return $frm->getfrm_input();
}
开发者ID:kumarsivarajan,项目名称:accounting-123,代码行数:8,代码来源:asset-autodep.php

示例15: getInstance

 public static function getInstance(OrderedItem $item, ProductFile $file)
 {
     $instance = $item->getRelatedRecordSet('OrderedFile', select(eq('OrderedFile.productFileID', $file->getID())))->shift();
     if (!$instance) {
         $instance = self::getNewInstance($item, $file);
     }
     return $instance;
 }
开发者ID:saiber,项目名称:livecart,代码行数:8,代码来源:OrderedFile.php


注:本文中的select函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。