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


PHP singleton::getInstance方法代码示例

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


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

示例1: validateAddPortfolio

 /**
  * validateAddPortfolio
  *
  * Validate new portfolio
  * @param($_POST)
  * @return(boolean)
  */
 public function validateAddPortfolio()
 {
     # get the modal
     $oPortfolio = singleton::getInstance('Portfolio');
     # the slug
     $page_slug = $_POST['page_slug'];
     # create empty error
     $aErrors = array();
     if (strlen($_POST['portfolio_title']) >= 30) {
         $aErrors['title'] = true;
     }
     if (strlen($_POST['portfolio_description']) >= 1000) {
         $aErrors['description'] = true;
     }
     if (strlen($_POST['portfolio_github_link']) >= 100) {
         $aErrors['github'] = true;
     }
     if (strlen($_POST['portfolio_website_link']) >= 100) {
         $aErrors['portfolio_website_link'] = true;
     }
     if (strlen($_POST['portfolio_meta_title']) >= 100) {
         $aErrors['portfolio_meta_title'] = true;
     }
     if (strlen($_POST['portfolio_meta_keyword']) >= 1000) {
         $aErrors['portfolio_meta_title'] = true;
     }
     if (strlen($_POST['portfolio_meta_desc']) >= 2) {
         $aErrors['portfolio_meta_desc'] = true;
     }
     if (strlen($page_slug) >= 25) {
         $aErrors['page_slug_too_long'] = true;
     }
     # check regex
     if (!preg_match('/^[a-z0-9-]+$/', $page_slug)) {
         $aErrors['not_a_valid_regex'] = true;
     }
     # check if availble
     if (!$oPortfolio->checkSlugAvailable($page_slug)) {
         $aErrors['slug_not_available'] = true;
     }
     if ($aErrors) {
         return var_dump($aErrors);
     } else {
         return true;
     }
 }
开发者ID:RhenusoneRosalia,项目名称:portfolio,代码行数:53,代码来源:PortfolioController.php

示例2: getInstance

 public static function getInstance($v4a8a08f09d37b73795649038408b5f33 = NULL)
 {
     return parent::getInstance(__CLASS__);
 }
开发者ID:BGCX261,项目名称:zimmerli-svn-to-git,代码行数:4,代码来源:umiHierarchyTypesCollection.php

示例3: getInstance

 public static function getInstance()
 {
     return parent::getInstance(get_class());
 }
开发者ID:ravenlp,项目名称:FlavorPHP,代码行数:4,代码来源:mysqli_db.class.php

示例4:

<?php

$oPortfolio = singleton::getInstance('Portfolio');
$oFile = singleton::getInstance('FileModel');
# get the portfolios amount
$countPortfolios = $oPortfolio->countPortfolios();
$oSmarty->assign('countPortfolios', $countPortfolios);
# get the users file amount
if ($oUser->isAdmin()) {
    $oSmarty->assign('countFiles', $oFile->countFiles($id = $oUser->getUserId(), $deleted = true));
} else {
    $oSmarty->assign('countFiles', $oFile->countFiles($id = $oUser->getUserId()));
}
开发者ID:RhenusoneRosalia,项目名称:portfolio,代码行数:13,代码来源:profile.inc.php

示例5: writeln

writeln('');

$bookBorrower2->borrowBook();
writeln('BookBorrower2 asked to borrow the book');
writeln('BookBorrower2 Author and Title: ');
writeln($bookBorrower2->getAuthorAndTitle());
writeln('');

$bookBorrower1->returnBook();
writeln('BookBorrower1 returned the book');
writeln('');

$bookBorrower2->borrowBook();
writeln('BookBorrower2 Author and Title: ');
writeln($bookBorrower1->getAuthorAndTitle());
writeln('');

writeln('END TESTING SINGLETON PATTERN');

function writeln($line_in) {
	echo $line_in.'<br/>';
}
*/
$connect = singleton::getInstance();
$query = $connect->sendQuery("select * from polo");
var_dump($connect);
$connect2 = singleton::getInstance();
var_dump($connect2);
while ($row = $connect->fetchArray($query)) {
    echo $row["nom"] . "<br>";
}
开发者ID:eandbteam,项目名称:design_patterns_php,代码行数:31,代码来源:singleton.php

示例6: countFiles

 /**
  * count all the files a user have
  * if and id is givin in it will get them from a specific user otherwise it will get them from the current user
  * if we also want to count the deleted files we can assign true to also get them
  * @param(int)
  * @return(int)
  */
 public function countFiles($idFromSlug = null, $deleted = false)
 {
     $oUser = singleton::getInstance('User');
     # the query
     $query = 'SELECT count(*) as countFiles FROM 
               files LEFT JOIN users on users.id = files.users_id ';
     # if idFromSlug specified get them from the user id
     if ($idFromSlug) {
         $query .= ' WHERE users.id = ' . $idFromSlug;
     } else {
         $query .= ' WHERE users.id = ' . $oUser->getUserId();
     }
     # get deleted files?
     if ($deleted) {
         $query .= ' and files.deleted = 0 ';
     }
     echo $query;
     exit;
     # execute
     $oResult = $this->mysqli->query($query);
     # fetch it
     $result = parent::fetchResultAssoc($oResult);
     # and return
     return $result[0]['countFiles'];
 }
开发者ID:RhenusoneRosalia,项目名称:portfolio,代码行数:32,代码来源:FileModel.php

示例7: header

<?php

if (!$_FILES && !$_POST) {
    echo "No direct access allowed";
    exit;
}
header('Content-type: application/json');
if (!empty($_FILES)) {
    // Get the file classes necessary to handle this request
    $oFileCtrl = Singleton::getInstance('FileController');
    // Controller
    $oFile = Singleton::getInstance('FileModel');
    // Model
    $oUpload = singleton::getInstance('Upload');
    // Utility
    # get the user file quota limit and check if he didn't pass it if he did we quit :)
    if (!$oFile->getUserQuota()) {
        header('HTTP/1.1 500 Internal Server Error');
        header('Content-type: text/plain');
        $msg = "Quota limit reached";
        exit($msg);
    }
    # get the file properties in an array
    $aFileInfo = $oUpload->getFileProperties($_FILES);
    # the tmp file properties
    $sExtension = $aFileInfo['sFileExt'];
    $sTmpName = $aFileInfo['sTmp_name'];
    $iFilesize = $aFileInfo['iFileSize'];
    $sOrg_fileName = $aFileInfo['sFilename'];
    # check if the extension is allowed exit script if not
    //$bFileExtensionStatus = $oFile->checkExtension($sExtension);
开发者ID:RhenusoneRosalia,项目名称:portfolio,代码行数:31,代码来源:uploader.php

示例8: ValidateFinishForm

 public function ValidateFinishForm()
 {
     # NO POST? exit
     if (!$_POST) {
         header('HTTP/1.1 500 Internal Server Error');
         header('Content-type: text/plain');
         $msg = "SORRY YOU CAN'T SUBMIT THIS FORM RIGHT NOW PLEASE COMEBACK LATER.";
         exit($msg);
     }
     $aErrors = array();
     # Load validation Module
     $oValidate = singleton::getInstance('Validation');
     # validate fields
     $oValidate->stringLength($_POST['first_name'], 3, 15);
     $oValidate->stringLength($_POST['last_name'], 3, 30);
     $oValidate->stringLength($_POST['facebook'], 0, 100);
     $oValidate->stringLength($_POST['instagram'], 0, 100);
     $oValidate->stringLength($_POST['twitter'], 0, 100);
     $oValidate->stringLength($_POST['website'], 0, 100);
     $oValidate->stringLength($_POST['linkedin'], 0, 100);
     # check firstname
     // if(strlen($_POST['first_name']) >= 15)
     //   $aErrors['first_name'] = true;
     // # check lastname
     // if(strlen($_POST['last_name']) >= 30)
     //   $aErrors['last_name'] = true;
     // # check pwd
     // if($_POST['password'] != $_POST['rpassword'])
     //   $aErrors['no_pwd_match'] = true;
     // # facebook
     // if(strlen($_POST['facebook']) >= 100)
     //   $aErrors['facebook'] = true;
     // # instagram
     // if(strlen($_POST['instagram']) >= 100)
     //   $aErrors['instagram'] = true;
     // # twitter
     // if(strlen($_POST['twitter']) >= 100)
     //   $aErrors['twitter'] = true;
     // # website
     // if(strlen($_POST['website']) >= 100)
     //   $aErrors['website'] = true;
     // # linkedin
     // if(strlen($_POST['linkedin']) >= 100)
     //   $aErrors['linkedin'] = true;
     #if there are errors return them now
     if ($aErrors) {
         return $aErrors;
     }
     $oUser = Singleton::getInstance('User');
     # get the id we do it here since the instance is already initaliazed
     $id = $oUser->getUserId();
     # if succeed redirect the user to the dashboard
     if ($oUser->finishAccount($id)) {
         return true;
     }
 }
开发者ID:RhenusoneRosalia,项目名称:portfolio,代码行数:56,代码来源:UserController.php

示例9: getInstance

 /**
  * Получить экземпляр коллекци
  * @return permissionsCollection экземпляр класса permissionsCollection
  */
 public static function getInstance($c = NULL)
 {
     return parent::getInstance(__CLASS__);
 }
开发者ID:BGCX261,项目名称:zimmerli-svn-to-git,代码行数:8,代码来源:permissionsCollection.php

示例10: array

<?php

$oUserCtrl = singleton::getInstance('UserController');
# check if the user has changed some of his settings
if ($_POST['firstname'] || $_POST['lastname'] || $_POST['mobile'] || $_POST['job-title'] || $_POST['text-area']) {
    $aErrors = $oUserCtrl->validateUserInfo();
    $oSmarty->assign('aErrors', $aErrors);
}
#require the check
require_once '../login_check.php';
require 'profile.inc.php';
# give page meta
$aMeta = array('title' => Language::getByName('instellingen'));
$oSmarty->assign('aMeta', $aMeta);
# give active class
$oSmarty->assign('activeClass', 'profile');
$oSmarty->assign('subActiveClass', 'settings');
# ok
$oSmarty->display('admin/profile/settings.tpl');
开发者ID:RhenusoneRosalia,项目名称:portfolio,代码行数:19,代码来源:settings.php

示例11: singleton

        $pos = 0;
        // 判断该类是否是第一次被实例化
        if (self::$instance == NULL) {
            self::$instance = new singleton();
            for ($i = 1; $i <= $location; $i++) {
                $pos = strpos($sql, '?', $pos + 1);
            }
        } else {
            for ($i = 1; $i <= $location - 1; $i++) {
                $pos = strpos($sql, '?', $pos + 1);
            }
        }
        return $sql = substr($sql, 0, $pos) . $var . substr($sql, $pos + 1);
    }
}
$dsn = "mysql:host=localhost;dbname=learnsql;charset=utf8";
$user = "root";
$pwd = "123456";
$pdo = new PDO($dsn, $user, $pwd);
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$pdo->exec("SET NAMES UTF8");
$uid = 10086;
$pwd = "pwd";
$uname = "yaohuang";
$sql = "SELECT*FROM tables WHERE uid=? AND uname=? AND pwd=?";
echo singleton::getInstance($sql, 1, $uid, 'INT');
echo "\n";
echo singleton::getInstance($sql, 3, $pwd, 'STRING');
echo "\n";
echo singleton::getInstance($sql, 2, $uname, 'STRING');
开发者ID:ZSShang,项目名称:mylearn,代码行数:30,代码来源:danli_static.php


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