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


PHP connection::getInstance方法代码示例

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


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

示例1: filter_input

 $formdata['password'] = filter_input($input_method, "password", FILTER_SANITIZE_STRING);
 //if any of the form fields are empty
 if (empty($formdata['username'])) {
     $errors['username'] = "Username required";
 }
 if (empty($formdata['password'])) {
     $errors['password'] = "Password required";
 }
 if (empty($errors)) {
     // since none of the form fields were empty,
     // store the form data in variables
     $username = $formdata['username'];
     $password = $formdata['password'];
     // create a UserTable object and use it to retrieve
     // the users
     $connection = connection::getInstance();
     $userTable = new UserTable($connection);
     $user = $userTable->getUserByUn($username);
     // since password fields match, see if the username
     // has already been registered - if it is then throw
     // and exception
     if ($user == null) {
         $errors['username'] = "Username is not registered";
     } else {
         if ($password !== $user->getPassword()) {
             $errors['password'] = "Password is incorrect";
         }
     }
 }
 if (!empty($errors)) {
     throw new Exception("There were errors. Please fix them.");
开发者ID:GitupPatsyy,项目名称:WEBPROGCA2,代码行数:31,代码来源:login.php

示例2: getAmount

 public function getAmount($type)
 {
     $b = connection::getInstance()->prepare("SELECT count(*) as count FROM {$type}");
     $b->execute();
     $resColumn = $b->fetchAll();
     if ($resColumn == null) {
         return null;
     }
     return $resColumn[0]["count"];
 }
开发者ID:JoaoBGusmao,项目名称:qualdosdois,代码行数:10,代码来源:class.question.php


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