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


PHP Database::singleton方法代码示例

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


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

示例1: __construct

 function __construct($helpid = null)
 {
     $sql = 'select * from help where helpid="' . $helpid . '"';
     $help = Database::singleton()->query_fetch($sql);
     $this->title = $help['title'];
     $this->body = $help['body'];
 }
开发者ID:swat30,项目名称:safeballot,代码行数:7,代码来源:Help.php

示例2: run

 /**
  * @url GET run
  * @param array $roleIds
  */
 public function run($roleIds = null)
 {
     try {
         $session = Session::singleton();
         $session->activateRoles($roleIds);
         // Check sessionRoles if allowedRolesForRunFunction is specified
         $allowedRoles = Config::get('allowedRolesForRunFunction', 'execEngine');
         if (!is_null($allowedRoles)) {
             $ok = false;
             foreach ($session->getSessionRoles() as $role) {
                 if (in_array($role->label, $allowedRoles)) {
                     $ok = true;
                 }
             }
             if (!$ok) {
                 throw new Exception("You do not have access to run the exec engine", 401);
             }
         }
         ExecEngine::run(true);
         $db = Database::singleton();
         $db->closeTransaction('Run completed', false, true, false);
         $result = array('notifications' => Notifications::getAll());
         return $result;
     } catch (Exception $e) {
         throw new RestException($e->getCode(), $e->getMessage());
     }
 }
开发者ID:4ZP6Capstone2015,项目名称:ampersand,代码行数:31,代码来源:ExecEngineApi.php

示例3: populateVisitLabel

/**
 * Adds the missing instruments based on the visit_label
 *
 * @param Array  $result      containing visit_label info
 * @param String $visit_label The name of the visit
 *
 * @return NULL
 */
function populateVisitLabel($result, $visit_label)
{
    global $argv, $confirm;
    // create a new battery object && new battery
    $battery = new NDB_BVL_Battery();
    // select a specific time point (sessionID) for the battery
    $battery->selectBattery($result['ID']);
    $timePoint = TimePoint::singleton($result['ID']);
    $DB = Database::singleton();
    $candidate = Candidate::singleton($result['CandID']);
    $result_firstVisit = $candidate->getFirstVisit();
    $isFirstVisit = false;
    //adding check for first visit
    if ($result_firstVisit == $visit_label) {
        $isFirstVisit = true;
    }
    //To assign missing instruments to all sessions, sent to DCC or not.
    $defined_battery = $battery->lookupBattery($battery->age, $result['subprojectID'], $timePoint->getCurrentStage(), $visit_label, $timePoint->getCenterID(), $isFirstVisit);
    $actual_battery = $battery->getBattery($timePoint->getCurrentStage(), $result['subprojectID'], $visit_label);
    $diff = array_diff($defined_battery, $actual_battery);
    if (!empty($diff)) {
        echo "\n CandID: " . $timePoint->getCandID() . "  Visit Label:  " . $timePoint->getVisitLabel() . "\nMissing Instruments:\n";
        print_r($diff);
    }
    if ($confirm === true) {
        foreach ($diff as $test_name) {
            $battery->addInstrument($test_name);
        }
    }
    unset($battery);
    unset($timePoint);
}
开发者ID:spaiva,项目名称:Loris,代码行数:40,代码来源:assign_missing_instruments.php

示例4: smarty_resource_db_timestamp

function smarty_resource_db_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj)
{
    $sql = 'select * from templates where path="' . $tpl_name . '" and module="' . $smarty_obj->compile_id . '" order by `timestamp` desc limit 1';
    $r = Database::singleton()->query_fetch($sql);
    $tpl_timestamp = strtotime($r['timestamp']);
    return true;
}
开发者ID:anas,项目名称:feedstore,代码行数:7,代码来源:resource.db.php

示例5: getAdminInterface

 public function getAdminInterface()
 {
     $st = "select ecomm_product.id as product_id, ecomm_product.name as product_name,\n\t\t\t\tecomm_product.supplier as supplier_id, ecomm_supplier.name as supplier_name, ecomm_product.price as product_price\n\t\t\t\tfrom ecomm_product left join ecomm_supplier on ecomm_product.supplier = ecomm_supplier.id\n\t\t\t\torder by ecomm_supplier.name,ecomm_product.name";
     $products = Database::singleton()->query_fetch_all($st);
     $formPath = "/admin/EComm&section=Plugins&page=ChangeProductPrice";
     $form = new Form('change_product_prices', 'post', $formPath);
     if ($form->validate() && isset($_REQUEST['submit'])) {
         foreach ($products as $product) {
             $ECommProduct = new Product($product['product_id']);
             $ECommProduct->setPrice($_REQUEST['product_' . $product['product_id']]);
             $ECommProduct->save();
         }
         return "Your products' prices have been changed successfully<br/><a href='{$formPath}'>Go back</a>";
     }
     $oldSupplier = 0;
     $currentSupplier = 0;
     $defaultValue = array();
     foreach ($products as $product) {
         $currentSupplier = $product['supplier_id'];
         if ($oldSupplier != $currentSupplier) {
             $form->addElement('html', '<br/><br/><hr/><h3>Supplier: ' . $product['supplier_name'] . '</h3>');
         }
         $form->addElement('text', 'product_' . $product['product_id'], $product['product_name']);
         $defaultValue['product_' . $product['product_id']] = $product['product_price'];
         $oldSupplier = $product['supplier_id'];
     }
     $form->addElement('submit', 'submit', 'Submit');
     $form->setDefaults($defaultValue);
     return $form->display();
 }
开发者ID:anas,项目名称:feedstore,代码行数:30,代码来源:ChangeProductPrice.php

示例6: run

 /**
  * @url GET run
  */
 public function run()
 {
     try {
         $session = Session::singleton();
         $db = Database::singleton();
         $allowedRoles = (array) Config::get('allowedRolesForRunFunction', 'execEngine');
         if (Config::get('loginEnabled') && !is_null($allowedRoles)) {
             $ok = false;
             $sessionRoles = Role::getAllSessionRoles();
             foreach ($sessionRoles as $role) {
                 if (in_array($role->label, $allowedRoles)) {
                     $ok = true;
                 }
             }
             if (!$ok) {
                 throw new Exception("You do not have access to run the exec engine", 401);
             }
         }
         $session->setRole();
         ExecEngine::runAllRules();
         $db->closeTransaction('Run completed', false, true, false);
         $result = array('notifications' => Notifications::getAll());
         return $result;
     } catch (Exception $e) {
         throw new RestException($e->getCode(), $e->getMessage());
     }
 }
开发者ID:4ZP6Capstone2015,项目名称:Capstone,代码行数:30,代码来源:ExecEngineApi.php

示例7: GetGruposByID

 public function GetGruposByID($id)
 {
     $bd = Database::singleton();
     $where = array("id" => $id);
     $result = $bd->Select("grupos", null, $where, null);
     return $result[0];
 }
开发者ID:jpizzolatto,项目名称:VirtualLibrary,代码行数:7,代码来源:GruposClass.php

示例8: GetAlbunsByName

 public function GetAlbunsByName($name)
 {
     $bd = Database::singleton();
     $where = array("nome" => $name);
     $result = $bd->Select("pastas", null, $where, null);
     return $result;
 }
开发者ID:jpizzolatto,项目名称:VirtualLibrary,代码行数:7,代码来源:PastasClass.php

示例9: saveMutation

 private static function saveMutation($operation, $fullRelationSignature, $stableAtom, $stableConcept, $modifiedAtom, $modifiedConcept, $source)
 {
     if (array_key_exists($fullRelationSignature, Config::get('mutationConcepts', 'MutationExtension'))) {
         Notifications::addLog("Save mutation on '{$fullRelationSignature}' (editUpdate)", 'Mutation');
         $mutConcept = Config::get('mutationConcepts', 'MutationExtension')[$fullRelationSignature];
         $database = Database::singleton();
         $database->setTrackAffectedConjuncts(false);
         // Don't track affected conjuncts for Mutation concept and relations;
         // New Mutation
         $mut = $database->addAtomToConcept(Concept::createNewAtom($mutConcept), $mutConcept);
         // Add mut info
         $database->editUpdate('mutRelation', false, $mut, 'Mutation', $fullRelationSignature, 'Relation');
         $database->editUpdate('mutDateTime', false, $mut, 'Mutation', date(DATE_ISO8601), 'DateTime');
         if ($source == 'User') {
             $user = Session::getSessionUserId();
         } else {
             $user = $source;
         }
         $database->editUpdate('mutBy', false, $mut, 'Mutation', $user, 'User');
         $database->editUpdate('mutOp', false, $mut, 'Mutation', $operation, 'Operation');
         // $database->editUpdate('mutReason', false, $mut, 'Mutation', 'zomaar', 'MutationReason'); // TODO: get reason from somewhere
         $database->editUpdate('mutValue', false, $mut, 'Mutation', $modifiedAtom, 'MutationValue');
         $database->editUpdate('mutStable', false, $mut, $mutConcept, $stableAtom, $stableConcept);
         $database->editUpdate('mutPublish', false, $mut, 'Mutation', $mut, 'Mutation');
         $database->setTrackAffectedConjuncts(true);
         // Enable tracking of affected conjuncts again!!
     }
 }
开发者ID:4ZP6Capstone2015,项目名称:ampersand,代码行数:28,代码来源:Mutation.php

示例10: getPropertiesBasedOnProductId

 public static function getPropertiesBasedOnProductId($productId)
 {
     if (!$productId) {
         return new ProductPropertiesTbl();
     }
     $sql = 'select `id` from ecomm_product_properties where product = "' . e($productId) . '"';
     $result = Database::singleton()->query_fetch($sql);
     return new ProductPropertiesTbl($result['id']);
 }
开发者ID:anas,项目名称:feedstore,代码行数:9,代码来源:ProductProperties.php

示例11: getAll

 public static function getAll()
 {
     $sql = 'select `id` from ecomm_transaction';
     $results = Database::singleton()->query_fetch_all($sql);
     foreach ($results as &$result) {
         $result = new Transaction($result['id']);
     }
     return $results;
 }
开发者ID:anas,项目名称:feedstore,代码行数:9,代码来源:Transaction.php

示例12: getAllReports

 public static function getAllReports()
 {
     $sql = 'select mso_id from mail_sendout order by mso_timestamp desc';
     $rs = Database::singleton()->query_fetch_all($sql);
     foreach ($rs as &$r) {
         $r = new MailReport($r['mso_id']);
     }
     return $rs;
 }
开发者ID:anas,项目名称:feedstore,代码行数:9,代码来源:MailReport.php

示例13: getPermissions

 public static function getPermissions()
 {
     $sql = 'select * from permissions';
     $p = Database::singleton()->query_fetch_all($sql);
     foreach ($p as &$perm) {
         $perm = new Permission($perm['id']);
     }
     return $p;
 }
开发者ID:swat30,项目名称:safeballot,代码行数:9,代码来源:Permission.php

示例14: setUp

 function setUp()
 {
     $client = new NDB_Client();
     $client->makeCommandLine();
     $client->initialize();
     $this->DB = Database::singleton();
     $this->DB->setFakeTableData("test_names", array(array('ID' => 1, 'Test_name' => 'ActiveTestByAge', 'Full_name' => 'Active Test 1', 'Sub_group' => 1, 'IsDirectEntry' => 0), array('ID' => 2, 'Test_name' => 'ActiveTestByAge2', 'Full_name' => 'Active Test 2', 'Sub_group' => 1, 'IsDirectEntry' => 0), array('ID' => 3, 'Test_name' => 'InactiveTest', 'Full_name' => 'Inactive Test 1', 'Sub_group' => 1, 'IsDirectEntry' => 0), array('ID' => 4, 'Test_name' => 'ActiveTestByVisit', 'Full_name' => 'Active Test by Visit 1', 'Sub_group' => 1, 'IsDirectEntry' => 0), array('ID' => 5, 'Test_name' => 'ActiveTestByVisit2', 'Full_name' => 'Active Test by Visit 2', 'Sub_group' => 1, 'IsDirectEntry' => 0), array('ID' => 6, 'Test_name' => 'ActiveTestByFirstVisit', 'Full_name' => 'Active Test by First Visit 2', 'Sub_group' => 1, 'IsDirectEntry' => 0), array('ID' => 7, 'Test_name' => 'ActiveTestByNotFirstVisit', 'Full_name' => 'Active Test by Not First Visit 2', 'Sub_group' => 1, 'IsDirectEntry' => 0)));
     $this->DB->setFakeTableData("test_battery", array(array('ID' => 1, 'Test_name' => 'ActiveTestByAge', 'AgeMinDays' => 0, 'AgeMaxDays' => 100, 'Active' => 'Y', 'Stage' => 'Visit', 'SubprojectID' => 1, 'Visit_label' => null, 'CenterID' => null, 'firstVisit' => null), array('ID' => 2, 'Test_name' => 'ActiveTestByAge2', 'AgeMinDays' => 0, 'AgeMaxDays' => 100, 'Active' => 'Y', 'Stage' => 'Visit', 'SubprojectID' => 1, 'Visit_label' => null, 'CenterID' => '1', 'firstVisit' => null), array('ID' => 3, 'Test_name' => 'InactiveTest', 'AgeMinDays' => 0, 'AgeMaxDays' => 0, 'Active' => 'N', 'Stage' => 'Visit', 'SubprojectID' => 2, 'Visit_label' => 'V01', 'CenterID' => '1', 'firstVisit' => null), array('ID' => 4, 'Test_name' => 'ActiveTestByVisit', 'AgeMinDays' => 0, 'AgeMaxDays' => 0, 'Active' => 'Y', 'Stage' => 'Visit', 'SubprojectID' => 2, 'Visit_label' => 'V01', 'CenterID' => null, 'firstVisit' => null), array('ID' => 5, 'Test_name' => 'ActiveTestByVisit2', 'AgeMinDays' => 0, 'AgeMaxDays' => 0, 'Active' => 'Y', 'Stage' => 'Visit', 'SubprojectID' => 2, 'Visit_label' => 'V01', 'CenterID' => '1', 'firstVisit' => null), array('ID' => 6, 'Test_name' => 'ActiveTestByFirstVisit', 'AgeMinDays' => 0, 'AgeMaxDays' => 100, 'Active' => 'Y', 'Stage' => 'Visit', 'SubprojectID' => 1, 'Visit_label' => null, 'CenterID' => '1', 'firstVisit' => 'Y'), array('ID' => 7, 'Test_name' => 'ActiveTestByNotFirstVisit', 'AgeMinDays' => 0, 'AgeMaxDays' => 100, 'Active' => 'Y', 'Stage' => 'Visit', 'SubprojectID' => 1, 'Visit_label' => null, 'CenterID' => '1', 'firstVisit' => 'N')));
 }
开发者ID:frankbiospective,项目名称:Loris,代码行数:9,代码来源:BatteryLookup_Test.php

示例15: testSetFakeData

 function testSetFakeData()
 {
     $client = new NDB_Client();
     $client->makeCommandLine();
     $client->initialize();
     $DB = Database::singleton();
     $DB->setFakeTableData("Config", array(0 => array('ID' => 99999, 'ConfigID' => '123456', 'Value' => 'FKE1234')));
     $allCandidates = $DB->pselect("SELECT * FROM Config", array());
     $this->assertEquals($allCandidates, array(0 => array('ID' => 99999, 'ConfigID' => 123456, 'Value' => 'FKE1234')));
 }
开发者ID:frankbiospective,项目名称:Loris,代码行数:10,代码来源:Database_Test.php


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