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


PHP get_first函数代码示例

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


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

示例1: view

 function view()
 {
     $post_id = $this->params[0];
     $this->post = get_first("SELECT * FROM post NATURAL JOIN user WHERE post_id='{$post_id}'");
     $this->tags = get_all("SELECT * FROM post_tags NATURAL JOIN tag WHERE post_id='{$post_id}'");
     $this->comments = get_all("SELECT * FROM comment WHERE post_id ='{$post_id}'");
 }
开发者ID:ramonp233,项目名称:blog,代码行数:7,代码来源:posts.php

示例2: require_auth

 /**
  * Verifies if the user is logged in and authenticates if not and POST contains username, else displays the login form
  * @return bool Returns true when the user has been logged in
  */
 function require_auth()
 {
     global $errors;
     // If user has already logged in...
     if ($this->logged_in) {
         return TRUE;
     }
     // Authenticate by POST data
     if (isset($_POST['username'])) {
         $username = $_POST['username'];
         $password = $_POST['password'];
         $user = get_first("SELECT user_id, is_admin FROM user\n                                WHERE username = '{$username}'\n                                  AND password = '{$password}'\n                                  AND  deleted = 0");
         if (!empty($user['user_id'])) {
             $_SESSION['user_id'] = $user['user_id'];
             $this->load_user_data($user);
             return true;
         } else {
             $errors[] = "Vale kasutajanimi või parool";
         }
     }
     // Display the login form
     require 'templates/auth_template.php';
     // Prevent loading the requested controller (not authenticated)
     exit;
 }
开发者ID:Aphyxia,项目名称:halo,代码行数:29,代码来源:Auth.php

示例3: view

 function view()
 {
     // TODO: Protect against SQL injections some day
     $course_id = $this->params[0];
     $this->course = get_first("SELECT * FROM course WHERE course_id = '{$course_id}'");
     $this->lessons = get_all("SELECT * FROM lesson WHERE course_id = '{$course_id}'");
 }
开发者ID:henno,项目名称:varamu,代码行数:7,代码来源:courses.php

示例4: edit

 function edit()
 {
     $broneering_id = $this->params[0];
     $this->broneering = get_first("SELECT * FROM broneering WHERE broneering_id = '{$broneering_id}'");
     $this->dates = get_all("SELECT * FROM kuupaev");
     $this->times = get_all("SELECT * FROM kellaeg");
 }
开发者ID:DataKeyt,项目名称:meliss,代码行数:7,代码来源:broneering.php

示例5: greedy_search

function greedy_search($start, $end)
{
    $first = array();
    for ($i = 0; $i < count($end); $i++) {
        $temp = get_first($start, $end, $first);
        $first[] = $temp;
    }
    var_dump($first);
}
开发者ID:LiosWang,项目名称:algorithm,代码行数:9,代码来源:greedy_algorithm.php

示例6: findTime

 public function findTime()
 {
     $time = get_first($this->request->get('subscr_date'), $this->request->get('payment_date'));
     if (!$time) {
         return parent::findTime();
     }
     $d = new DateTime($time);
     $d->setTimezone(new DateTimeZone(date_default_timezone_get()));
     return $d;
 }
开发者ID:alexanderTsig,项目名称:arabic,代码行数:10,代码来源:Paypal.php

示例7: validate

 /**
  * Validate key and UID with database and return code instance if valid.
  * Returns false if combination is invalid.
  *
  * @param string $key
  * @param string $uid
  * @return System\User\Auth\Code|false
  */
 public static function validate($key, $uid)
 {
     $conds = array("valid" => true, "key" => $key, "uid" => $uid);
     $code = get_first('\\System\\User\\Auth\\Code')->where($conds)->fetch();
     if ($code) {
         if ($code->used == 0 || !$code->one_time) {
             $code->used = $code->used + 1;
             if ($code->one_time) {
                 $code->drop();
             } else {
                 $code->save();
             }
             return $code;
         } else {
             $code->drop();
         }
     }
     return false;
 }
开发者ID:just-paja,项目名称:fudjan-auth,代码行数:27,代码来源:code.php

示例8: get_income_report

function get_income_report()
{
    global $t, $vars, $db, $config;
    $report_days = get_first($GLOBALS['config']['payment_report_num_days'], 7);
    // get income
    $beg_tm = date('Y-m-d 00:00:00', time() - 3600 * $report_days * 24);
    $end_tm = date('Y-m-d 23:59:59', time());
    $res = array();
    $q = $db->query("SELECT FROM_DAYS(TO_DAYS(tm_added)) as date,\n        count(payment_id) as added_count, sum(amount) as added_amount\n        FROM {$db->config[prefix]}payments p\n        WHERE tm_added BETWEEN '{$beg_tm}' AND '{$end_tm}'\n        GROUP BY date\n        ");
    while ($x = mysql_fetch_assoc($q)) {
        $res[$x['date']] = $x;
    }
    $q = $db->query("SELECT FROM_DAYS(TO_DAYS(tm_completed)) as date,\n        count(payment_id) as completed_count, sum(amount) as completed_amount\n        FROM {$db->config[prefix]}payments p\n        WHERE tm_completed BETWEEN '{$beg_tm}' AND '{$end_tm}'\n        AND completed>0\n        GROUP BY date\n        ");
    $max_total = 0;
    while ($x = mysql_fetch_assoc($q)) {
        $res[$x['date']] = array_merge((array) $x, (array) $res[$x['date']]);
        $total_completed += $x['completed_amount'];
        if ($x['completed_amount'] > $max_total) {
            $max_total = $x['completed_amount'];
        }
    }
    $res1 = array();
    list($ty, $tm, $td) = split('-', date('Y-m-d'));
    $rtime = mktime(12, 0, 0, $tm, $td, $ty);
    for ($i = 0; $i < $report_days; $i++) {
        $dp = strftime("%a&nbsp;" . $config['date_format'], $rtime - $i * 3600 * 24);
        $d = date('Y-m-d', $rtime - $i * 3600 * 24);
        $res1[$d]['date'] = $d;
        $res1[$d]['date_print'] = $dp;
        $res1[$d]['added_count'] = intval($res[$d]['added_count']);
        $res1[$d]['completed_count'] = intval($res[$d]['completed_count']);
        $res1[$d]['added_amount'] = number_format($res[$d]['added_amount'], 2, '.', ',');
        $res1[$d]['completed_amount'] = number_format($res[$d]['completed_amount'], 2, '.', ',');
        if ($max_total) {
            $res1[$d]['percent_v'] = round(100 * $res[$d]['completed_amount'] / $max_total);
            $res1[$d]['percent'] = round(100 * $res[$d]['completed_amount'] / $total_completed);
        }
    }
    ksort($res1);
    return $res1;
}
开发者ID:subashemphasize,项目名称:test_site,代码行数:41,代码来源:index.php

示例9: getOkUrl

 public function getOkUrl()
 {
     return get_first($this->redirect_url, $this->getConfiguredRedirect());
 }
开发者ID:subashemphasize,项目名称:test_site,代码行数:4,代码来源:LoginController.php

示例10: getOkUrl

 public function getOkUrl()
 {
     $event = new Am_Event(Am_Event::AUTH_GET_OK_REDIRECT, array('user' => $this->getDi()->user));
     $event->setReturn($this->getConfiguredRedirect());
     $this->getDi()->hook->call($event);
     return get_first($this->redirect_url, $event->getReturn());
 }
开发者ID:alexanderTsig,项目名称:arabic,代码行数:7,代码来源:LoginController.php

示例11: log

 function log($invoice_id, $paysys_id, $title, $vars = null, $type = 'info', $remote_addr = null, $tm = null)
 {
     $r = $this->createRecord();
     if ($invoice = $this->getDi()->invoiceTable->load($invoice_id, false)) {
         $r->setInvoice($invoice);
     }
     $r->paysys_id = $paysys_id;
     $r->title = $title;
     $r->remote_addr = get_first($remote_addr, $_SERVER['REMOTE_ADDR']);
     $r->add($vars, false);
     $r->insert();
     return $r;
 }
开发者ID:alexanderTsig,项目名称:arabic,代码行数:13,代码来源:InvoiceLog.php

示例12: doWork


//.........这里部分代码省略.........
             $invoice->first_total = $signup_params['mc_gross'];
             $item = current($invoice->getItems());
             $invoice->first_period = $item->first_period;
             $invoice->status = Invoice::PAID;
         } else {
             // recurring
             if ($signup_params) {
                 $invoice->first_period = $invoice->second_period = strtolower(str_replace(' ', '', $signup_params['period3']));
                 $invoice->first_total = $invoice->second_total = $signup_params['mc_amount3'];
                 if (!empty($signup_params['mc_amount1'])) {
                     $invoice->first_total = $signup_params['mc_amount1'];
                     $invoice->first_period = strtolower(str_replace(' ', '', $signup_params['period1']));
                 }
                 if (!$signup_params['recurring']) {
                     $invoice->rebill_times = 1;
                 } elseif ($signup_params['recur_times']) {
                     $invoice->rebill_times = $signup_params['recur_times'];
                 } else {
                     $invoice->rebill_times = IProduct::RECURRING_REBILLS;
                 }
             } else {
                 // get terms from products
                 foreach ($product_ids as $pid => $count) {
                     $newPid = $this->_translateProduct($pid);
                     if (!$newPid) {
                         continue;
                     }
                     $pr = Am_Di::getInstance()->productTable->load($newPid);
                     $invoice->first_total += $pr->getBillingPlan()->first_price;
                     $invoice->first_period = $pr->getBillingPlan()->first_period;
                     $invoice->second_total += $pr->getBillingPlan()->second_price;
                     $invoice->second_period = $pr->getBillingPlan()->second_period;
                     $invoice->rebill_times = max(@$invoice->rebill_times, $pr->getBillingPlan()->rebill_times);
                 }
                 $invoice->rebill_times = IProduct::RECURRING_REBILLS;
             }
             if (@$txn_types['subscr_eot']) {
                 $invoice->status = Invoice::RECURRING_FINISHED;
             } elseif (@$txn_types['subscr_cancel']) {
                 $invoice->status = Invoice::RECURRING_CANCELLED;
                 foreach ($list as $p) {
                     if (!empty($p['data']['CANCELLED_AT'])) {
                         $invoice->tm_cancelled = sqlTime($p['data']['CANCELLED_AT']);
                     }
                 }
             } elseif (@$txn_types['subscr_payment']) {
                 $invoice->status = Invoice::RECURRING_ACTIVE;
             }
             $invoice->data()->set('paypal_subscr_id', $group_id);
         }
         foreach ($list as $p) {
             $pidlist[] = $p['payment_id'];
         }
         $invoice->data()->set('am3:id', implode(',', $pidlist));
         $invoice->insert();
         // insert payments and access
         foreach ($list as $p) {
             $newP = $this->_translateProduct($p['product_id']);
             $tm = null;
             $txnid = null;
             foreach ($p['data'] as $k => $d) {
                 if (is_int($k) && !empty($d['payment_date'])) {
                     $tm = $d['payment_date'];
                 }
                 if (is_int($k) && !empty($d['txn_id'])) {
                     $txnid = $d['txn_id'];
                 }
             }
             $tm = new DateTime(get_first(urldecode($tm), urldecode($p['tm_completed']), urldecode($p['tm_added']), urldecode($p['begin_date'])));
             $payment = $this->getDi()->invoicePaymentRecord;
             $payment->user_id = $this->user->user_id;
             $payment->invoice_id = $invoice->pk();
             $payment->amount = $p['amount'];
             $payment->paysys_id = 'paypal';
             $payment->dattm = $tm->format('Y-m-d H:i:s');
             if ($txnid) {
                 $payment->receipt_id = $txnid;
             }
             $payment->transaction_id = $txnid ? $txnid : 'import-paypal-' . mt_rand(10000, 99999);
             $payment->insert();
             $this->getDi()->db->query("INSERT INTO ?_data SET\n                    `table`='invoice_payment',`id`=?d,`key`='am3:id',`value`=?", $payment->pk(), $p['payment_id']);
             if ($newP) {
                 $a = $this->getDi()->accessRecord;
                 $a->user_id = $this->user->user_id;
                 $a->setDisableHooks();
                 $a->begin_date = $p['begin_date'];
                 /// @todo handle payments that were cancelled but still active in amember 3.  Calculate expire date in this case.
                 if (($p['expire_date'] == self::AM3_RECURRING_DATE || $p['expire_date'] == self::AM3_LIFETIME_DATE) && array_key_exists('subscr_cancel', $txn_types)) {
                     $a->expire_date = $invoice->calculateRebillDate(count($list));
                 } else {
                     $a->expire_date = $p['expire_date'];
                 }
                 $a->invoice_id = $invoice->pk();
                 $a->invoice_payment_id = $payment->pk();
                 $a->product_id = $newP;
                 $a->insert();
             }
         }
     }
 }
开发者ID:subashemphasize,项目名称:test_site,代码行数:101,代码来源:AdminImport3Controller.php

示例13: update

 function update()
 {
     $this->status = get_first($this->status, self::STATUS_CHANGED);
     parent::update();
 }
开发者ID:grlf,项目名称:eyedock,代码行数:5,代码来源:State.php

示例14: scan_file

 function scan_file($filename, $use_chunks = true, $max_chunks = 255, $chunk_size = 256, $progresslistener = null)
 {
     global $verbose;
     if ($verbose) {
         print "Scanning file..." . PHP_EOL;
     }
     // Filename and size
     $this->filename = basename($filename);
     if (!$this->hashes->filename) {
         $this->hashes->filename = $this->filename;
     }
     $size = filesize($filename);
     $this->size = (string) $size;
     $piecelength_ed2k = 9728000;
     $known_hashes = $this->hashes->get_multiple('ed2k md5 sha1 sha256');
     // If all hashes and pieces are already known, do nothing
     if (4 == sizeof($known_hashes) && $this->hashes->pieces) {
         return true;
     }
     // Calculate piece $length
     if ($use_chunks) {
         $minlength = $chunk_size * 1024;
         $this->hashes->piecelength = 1024;
         while ($size / $this->hashes->piecelength > $max_chunks || $this->hashes->piecelength < $minlength) {
             $this->hashes->piecelength *= 2;
         }
         if ($verbose) {
             print "Using piecelength " . $this->hashes->piecelength . " (" . $this->hashes->piecelength / 1024 . " KiB)" . PHP_EOL;
         }
         $numpieces = $size / $this->hashes->piecelength;
         if ($numpieces < 2) {
             $use_chunks = false;
         }
     }
     $hashes = array();
     // Try to use hash extension
     if (extension_loaded('hash')) {
         $hashes['md4'] = hash_init('md4');
         $hashes['md5'] = hash_init('md5');
         $hashes['sha1'] = hash_init('sha1');
         $hashes['sha256'] = hash_init('sha256');
         $piecehash = hash_init('sha1');
         $md4piecehash = null;
         if ($size > $piecelength_ed2k) {
             $md4piecehash = hash_init('md4');
             $length_ed2k = 0;
         }
     } else {
         print "Hash extension not available. No support for SHA-256 and ED2K." . PHP_EOL;
         $hashes['md4'] = null;
         $hashes['md5'] = null;
         $hashes['sha1'] = null;
         $hashes['sha256'] = null;
         $piecehash = '';
     }
     $piecenum = 0;
     $length = 0;
     // If some hashes are already available, do not calculate them
     if (isset($known_hashes['ed2k'])) {
         $known_hashes['md4'] = $known_hashes['ed2k'];
         unset($known_hashes['ed2k']);
     }
     foreach (array_keys($known_hashes) as $hash) {
         $hashes[$hash] = null;
     }
     // TODO: Don't calculate pieces if already known
     $this->hashes->pieces = array();
     if (!$this->hashes->piecetype) {
         $this->hashes->piecetype = "sha1";
     }
     $num_reads = ceil($size / 4096.0);
     $reads_per_progress = (int) ceil($num_reads / 100.0);
     $reads_left = $reads_per_progress;
     $progress = 0;
     $fp = fopen($filename, "rb");
     while (true) {
         $data = fread($fp, 4096);
         if ($data == "") {
             break;
         }
         // Progress updating
         if ($progresslistener) {
             $reads_left -= 1;
             if ($reads_left <= 0) {
                 $reads_left = $reads_per_progress;
                 $progress += 1;
                 $result = $progresslistener->Update($progress);
                 if (get_first($result) == false) {
                     if ($verbose) {
                         print "Cancelling scan!" . PHP_EOL;
                     }
                     return false;
                 }
             }
         }
         // Process the $data
         if ($hashes['md5']) {
             hash_update($hashes['md5'], $data);
         }
         if ($hashes['sha1']) {
//.........这里部分代码省略.........
开发者ID:j883376,项目名称:metalink-library,代码行数:101,代码来源:metalink.php

示例15: edit

 function edit()
 {
     $user_id = $this->params[0];
     $this->user = get_first("SELECT * FROM user WHERE user_id = '{$user_id}'");
 }
开发者ID:PindsterY,项目名称:Meliss,代码行数:5,代码来源:users.php


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