本文整理汇总了PHP中MySQL::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP MySQL::getInstance方法的具体用法?PHP MySQL::getInstance怎么用?PHP MySQL::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MySQL
的用法示例。
在下文中一共展示了MySQL::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
public function get($data = null)
{
parent::__construct(array(), ArrayObject::ARRAY_AS_PROPS);
if (is_array($data)) {
foreach ($data as $key => $value) {
if (is_array($value)) {
$value = new self($value);
}
$this->offsetSet($key, $value);
}
} else {
if ($data instanceof self) {
$data = $this->toArray($data);
$this->get($data);
} else {
if (is_string($data)) {
$db = MySQL::getInstance();
$db->query($data);
if ($db->numRows() > 0) {
$this->get($db->fetchRow());
}
}
}
}
return $this;
}
示例2: updateSorting
public function updateSorting($itemID, $sorting)
{
$db = MySQL::getInstance();
foreach ($sorting as $position => $id) {
$db->query("UPDATE `catalog_image` SET `Position` = " . $db->escape((int) $position) . "\n\t\t\t\tWHERE ItemID = " . $db->escape($itemID) . " AND ImageID = " . $db->escape((int) $id));
}
}
示例3: getSuburbMetroARIA
function getSuburbMetroARIA($suburbName)
{
$query = MySQL::getInstance()->prepare("SELECT MIN(metroariac) as minariac, ROUND(AVG(metroariac),0) as avgariac, MAX(metroariac) as maxariac,\n\t\t\t\tMIN(metroedu) as minedu, ROUND(AVG(metroedu),0) as avgedu, MAX(metroedu) as maxedu,\n\t\t\t\tMIN(metrofinpost) as minfinpost, ROUND(AVG(metrofinpost),0) as avgfinpost, MAX(metrofinpost) as maxfinpost,\n\t\t\t\tMIN(metrohealth) as minhealth, ROUND(AVG(metrohealth),0) as avghealth, MAX(metrohealth) as maxhealth,\n\t\t\t\tMIN(metrotransport) as mintransport, ROUND(AVG(metrotransport),0) as avgtransport, MAX(metrotransport) as maxtransport,\n\t\t\t\tMIN(metroshop) as minshop, ROUND(AVG(metroshop),0) as avgshop, MAX(metroshop) as maxshop,\n\t\t\t\tCOUNT(metroariac) as cnt FROM metro WHERE locality = :suburbName");
$query->bindValue("suburbName", $suburbName, PDO::PARAM_STR);
$query->execute();
return $query->fetchALL();
}
示例4: send_payload
function send_payload($payload)
{
$query = MySQL::getInstance()->prepare("INSERT INTO queue (payload) VALUES (:payload)");
$query->bindValue(':payload', $payload, PDO::PARAM_STR);
$query->execute();
log_operation('send');
}
示例5: updateSorting
public function updateSorting($newsletterID, $sorting)
{
$db = MySQL::getInstance();
foreach ($sorting as $position => $id) {
$db->query("UPDATE newsletter_image SET `Position` = " . $db->escape((int) $position) . "\n\t\t\t\tWHERE NewsletterID = " . $db->escape($newsletterID) . " AND ImageID = " . $db->escape((int) $id));
}
}
示例6: save_comment
function save_comment($article_id, $name, $body)
{
$query = MySQL::getInstance()->prepare("INSERT INTO comments (article_id, name, body) VALUES (:article_id, :name, :body)");
$query->bindValue(':article_id', $article_id, PDO::PARAM_INT);
$query->bindValue(':name', $name, PDO::PARAM_STR);
$query->bindValue(':body', $body, PDO::PARAM_STR);
$query->execute();
}
示例7: __construct
public function __construct(Request $request)
{
$this->_request = $request;
$this->_template = new Template();
$this->_template->_controller($request->controller())->_module($request->module())->_action($request->action());
$params = array('user' => 'sharpy', 'password' => 'sharpy', 'dbname' => 'sharpy', 'host' => 'localhost');
$this->_db = MySQL::getInstance($params);
}
示例8: findPage
public static function findPage(Controller $oController)
{
if (self::$currentPageID > 0) {
return;
}
if ($oController->indexPage()) {
$oPage = new Page();
if ($oPage->loadIndexPage()) {
if (Controller::getInstance()->controllerExists($oPage["Link"])) {
$oController->route[self::$level] = $oPage["Link"];
}
self::$level = 1;
self::$page = $oPage;
self::$currentPageID = $oPage->PageID;
}
} else {
$db = MySQL::getInstance();
$db->query("SELECT PageID, StaticPath, Level, LeftKey, RightKey, Link\n\t\t\t\tFROM `page` WHERE\n\t\t\t\t\tWebsiteID = " . $db->escape(WEBSITE_ID) . "\n\t\t\t\t\tAND StaticPath IN (" . implode(", ", $db->escape($oController->route)) . ")\n\t\t\t\t\tAND LanguageCode = " . $db->escape(LANG) . "\n\t\t\t\t\tAND Level > 1\n\t\t\t\tORDER BY LeftKey");
self::$level = 0;
$moduleFound = false;
$currentPageID = null;
while ($row = $db->fetchRow()) {
if ($row["StaticPath"] == $oController->route[0] && $row["Level"] == 2) {
$currentPageID = $row["PageID"];
self::$currentLeftKey = $row["LeftKey"];
self::$currentRightKey = $row["RightKey"];
if ($moduleFound = Controller::getInstance()->controllerExists($row["Link"])) {
$oController->route[0] = $row["Link"];
break;
}
self::$level++;
continue;
}
if (!is_null($currentPageID) && count($oController->route) > self::$level) {
if ($row["StaticPath"] == $oController->route[self::$level] && $row["LeftKey"] > self::$currentLeftKey && $row["RightKey"] < self::$currentRightKey) {
$currentPageID = $row["PageID"];
self::$currentLeftKey = $row["LeftKey"];
self::$currentRightKey = $row["RightKey"];
if ($moduleFound = Controller::getInstance()->controllerExists($row["Link"])) {
$oController->route[self::$level] = $row["Link"];
break;
}
self::$level++;
}
}
}
if (self::$level == count($oController->route) || $moduleFound != false) {
$oPage = new Page();
if ($oPage->loadByID($currentPageID)) {
self::$page = $oPage;
self::$currentPageID = $oPage->PageID;
}
}
}
for ($i = 0; $i < self::$level; $i++) {
array_shift($oController->route);
}
}
示例9: getKeys
private static function getKeys()
{
self::$vars = new Object();
$db = MySQL::getInstance();
$db->query('SELECT FieldName, FieldValue FROM `config`');
while (list($key, $value) = $db->fetchRow()) {
self::$vars->{$key} = $value;
}
self::$vars->Page = 1;
}
示例10: load
public function load($id = null)
{
$db = MySQL::getInstance();
$db->query("SELECT * FROM `user` WHERE `UserID` = " . $db->escape((int) $id) . "");
if ($row = $db->fetchRow()) {
$this->data = $row;
$this->loaded = true;
}
return $this;
}
示例11: deleteFile
public function deleteFile($ID)
{
$db = MySQL::getInstance();
$db->query("SELECT `Image` FROM `catalog_brand` WHERE `BrandID` =" . $db->escape($ID));
$fileName = $db->fetchField();
if (!empty($fileName)) {
File::delete($fileName, 'var/brand/');
File::delete('thumb_' . $fileName, 'var/brand/');
}
$db->query("UPDATE `catalog_brand` SET `Image` = NULL WHERE `BrandID` =" . $db->escape($ID));
}
示例12: isEmptyProperty
public function isEmptyProperty($id)
{
$db = MySQL::getInstance();
$db->query("SELECT * FROM `catalog_property` WHERE `CategoryID` = " . $id);
if ($db->numRows() == 0) {
return true;
} else {
throw new Exception(lang('к подгруппе привязаны свойства..'));
return false;
}
}
示例13: delete
public function delete()
{
if (!empty($this->data[0])) {
$db = MySQL::getInstance();
$db->query("SELECT `FieldValue` FROM `config` WHERE `FieldName` = " . $db->escape($this->data[0]));
if ($fileName = $db->fetchField()) {
File::delete($fileName, 'var/upload/');
$db->query("UPDATE `config` SET `FieldValue` = '' WHERE `FieldName` = " . $db->escape($this->data[0]));
}
}
redirect(BASE_PATH . 'admin/cp');
}
示例14: __construct
/**
* Start testing
*
* @return void
*/
public function __construct()
{
// Set text on browser
if (php_sapi_name() != 'cli') {
header('Content-type: text/plain');
}
// Set object
$this->_object = MySQL::getInstance();
// Get tests
$tests = get_class_methods($this);
// Set print mask
$masker = "| %-30.30s | %7s |" . PHP_EOL;
// Print header
printf($masker, '------------------------------', '-------');
printf($masker, 'Test', 'Result');
printf($masker, '------------------------------', '-------');
// Load db first
$link = mysql_connect(TEST_HOST, TEST_USER, TEST_PASS);
$statements = explode(';', file_get_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'MySQL_Test_Schema.sql'));
foreach ($statements as $statement) {
mysql_query(trim($statement)) or die(mysql_error());
}
mysql_close($link);
// Go through each test
foreach ($tests as $test) {
// Skip private/protected methods
if (substr($test, 0, 1) == '_') {
continue;
}
// Get mysql_* method
$name = strtolower(str_replace('_Test', '', $test));
// Increment # of tests
$this->results['tests']++;
// If it doesn't exist, naf it (not a function)
if (!function_exists($name)) {
$this->results['naf']++;
printf($masker, $test, 'NAF');
continue;
}
// Run tests
if ($this->{$test}()) {
$this->results['valid']++;
printf($masker, $test, 'Success');
} else {
$this->results['invalid']++;
printf($masker, $test, 'Failure');
}
}
// Print footer
printf($masker, '------------------------------', '-------');
}
示例15: get_resource_type_custom
function get_resource_type_custom($resource)
{
return MySQL::getInstance()->get_resource_type($resource);
}