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


PHP Connector::get_connection方法代码示例

本文整理汇总了PHP中Connector::get_connection方法的典型用法代码示例。如果您正苦于以下问题:PHP Connector::get_connection方法的具体用法?PHP Connector::get_connection怎么用?PHP Connector::get_connection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Connector的用法示例。


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

示例1: get_total_amount_of

 private function get_total_amount_of($type, $date)
 {
     $mysqli = Connector::get_connection();
     $query_result = $mysqli->query("SELECT sum(amount) FROM {$type}s  WHERE date = '{$date}' AND user_id = {$_SESSION['id_user']}");
     $result = $query_result->fetch_assoc();
     return format_amount($result['sum(amount)']);
     $mysqli->close();
 }
开发者ID:andriykonoz,项目名称:cashTracer,代码行数:8,代码来源:model_statistic.php

示例2: get_data

 public function get_data()
 {
     $mysqli = Connector::get_connection();
     $res = $mysqli->query("SELECT * FROM spending_categories");
     $spend_categories = array();
     while ($row = $res->fetch_assoc()) {
         $spend_categories[] = $row["name"];
     }
     $res = $mysqli->query("SELECT * FROM earning_categories");
     $profit_categories = array();
     while ($row = $res->fetch_assoc()) {
         $profit_categories[] = $row["name"];
     }
     return array($spend_categories, $profit_categories);
 }
开发者ID:andriykonoz,项目名称:cashTracer,代码行数:15,代码来源:model_main.php

示例3: set_data

 public function set_data()
 {
     $mysqli = Connector::get_connection();
     session_start();
     $category = trim($_POST["category"]);
     $cost = $_POST["amount"];
     $category_type = $_POST["category_type"];
     // Checking where year and month is numbers
     if (is_numeric(trim($_POST['year'])) && is_numeric(trim($_POST['month']))) {
         $date = trim($_POST['year']) . '-' . trim($_POST['month']) . '-00';
         // Checking of category
         if ($this->type_valid($category_type)) {
             $statement = $mysqli->prepare("SELECT id FROM {$category_type}_categories WHERE name = ?");
             $statement->bind_param("s", $category);
             $statement->execute();
             $statement->bind_result($category_id);
             $statement->fetch();
             // If received category cant be finded in database then null will be returned.
             // Here returned value checked for null.
             if (!empty($category_id)) {
                 if (is_numeric($cost)) {
                     $cost = floatval($cost);
                     $category_id = intval($category_id);
                     $mysqli = Connector::get_connection();
                     $statement = $mysqli->prepare("INSERT INTO {$category_type}s (category, amount, date, user_id) VALUES (?,?,?,?)");
                     $statement->bind_param("idsi", $category_id, $cost, $date, $_SESSION['id_user']);
                     $statement->execute();
                 } else {
                     echo "Error occured! 'Cost' value must be number, cost = " . $cost . "<br>";
                 }
             } else {
                 echo "Error occured! Cant find category '" . $category . "'<br>";
             }
         } else {
             echo "Error occured! Incorrect date: '" . $date . "'<br>";
         }
     }
     $mysqli->close();
 }
开发者ID:andriykonoz,项目名称:cashTracer,代码行数:39,代码来源:model_update.php

示例4: restore_password

 function restore_password()
 {
     $data = array();
     $login = $_POST['login'];
     $email = $_POST['email'];
     $mysqli = Connector::get_connection();
     $statement = $mysqli->prepare("SELECT id_user, mail_user FROM users WHERE login_user = ?");
     $statement->bind_param('s', $login);
     $statement->bind_result($selected_id, $selected_email);
     $statement->execute();
     $statement->fetch();
     $data['trace'] = $selected_email;
     if ($email == $selected_email) {
         $new_password = $this->generateCode(8);
         $message = "You request password recovery on the web-cite 'Finance account' for account {$login}\n\n            Your new password is {$new_password}\n";
         $headers = 'From: andriykonoz@gmail.com' . "\r\n" . 'Reply-To: andriykonoz@gmail.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
         if (mail($email, "Password recovery", $message, $headers)) {
             $mysqli = Connector::get_connection();
             $statement = $mysqli->prepare("UPDATE users SET passwd_user=? WHERE id_user=?");
             $statement->bind_param('ss', $new_password, $selected_id);
             $statement->execute();
         } else {
             $data['errors'] = 'Cant send email. Please, contact administrator';
         }
     } else {
         $data['errors'] = 'Incorrect email!';
     }
     return $data;
 }
开发者ID:andriykonoz,项目名称:cashTracer,代码行数:29,代码来源:model_authorize.php

示例5: get_graphics_json_data

 function get_graphics_json_data()
 {
     $mysqli = Connector::get_connection();
     return json_encode(array('earnings' => $this->fetch_data('earning', $mysqli), 'spendings' => $this->fetch_data('spending', $mysqli), 'global' => $this->fetch_global_data($mysqli)));
 }
开发者ID:andriykonoz,项目名称:cashTracer,代码行数:5,代码来源:model_graphics.php


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