本文整理汇总了PHP中sDB::get方法的典型用法代码示例。如果您正苦于以下问题:PHP sDB::get方法的具体用法?PHP sDB::get怎么用?PHP sDB::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sDB
的用法示例。
在下文中一共展示了sDB::get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
/**
* Save an asset to the database
*
* @author Jonathan Davis
* @since 1.1
*
* @param Asset $asset Asset object the data is associated with
* @param string $data Binary data or path to the file to be saved
* @param string $type (optional) Type of data provided - binary (default) or file
* @return string|boolean A URI for the resource or false if failed
**/
public function save($asset, $data, $type = 'binary')
{
if (empty($data)) {
return false;
}
if ('binary' != $type) {
if (!is_readable($data)) {
die("Could not read the file.");
}
// Die because we can't use ShoppError
$data = file_get_contents($data);
}
$data = @mysqli_real_escape_string(sDB::get()->dbh, $data);
if (!$asset->id) {
$uri = sDB::query("INSERT {$this->_table} SET data='{$data}'");
} else {
sDB::query("UPDATE {$this->_table} SET data='{$data}' WHERE {$this->_key}='{$asset->uri}'");
}
if (isset($uri)) {
return $uri;
}
return false;
}
示例2: found
/**
* Provides the number of records found in the last query
*
* @author Jonathan Davis
* @since 1.0
*
* @return int The number of records found
**/
public static function found()
{
$db = sDB::get();
$found = $db->found;
$db->found = false;
return $found;
}
示例3: upgrade_110
/**
* Shopp 1.1.0 upgrades
*
* @author Jonathan Davis
* @since 1.1
*
* @return void
**/
public function upgrade_110()
{
// 1.1 schema changes
$db_version = ShoppSettings::dbversion();
if ($db_version < 1100) {
return;
}
// Skip db_version is not less than 1100
$this->upschema('schema-110.sql');
$meta_table = ShoppDatabaseObject::tablename('meta');
$setting_table = ShoppDatabaseObject::tablename('setting');
$product_table = ShoppDatabaseObject::tablename('product');
// Update product status from the 'published' column
sDB::query("UPDATE {$product_table} SET status=CAST(published AS unsigned)");
// Set product publish date based on the 'created' date column
sDB::query("UPDATE {$product_table} SET publish=created WHERE status='publish'");
// Update Catalog
$catalog_table = ShoppDatabaseObject::tablename('catalog');
sDB::query("UPDATE {$catalog_table} set parent=IF(category!=0, category, tag), type=IF(category!=0, 'category', 'tag')");
// Update specs
$meta_table = ShoppDatabaseObject::tablename('meta');
$spec_table = ShoppDatabaseObject::tablename('spec');
$now = current_time('mysql');
sDB::query("INSERT INTO {$meta_table} (parent, context, type, name, value, numeral, sortorder, created, modified)\n\t\t\t\t\tSELECT product, 'product', 'spec', name, content, numeral, sortorder, '{$now}', '{$now}' FROM {$spec_table}");
// Update purchase table
$purchase_table = ShoppDatabaseObject::tablename('purchase');
sDB::query("UPDATE {$purchase_table} SET txnid=transactionid, txnstatus=transtatus");
// Update image assets
$meta_table = ShoppDatabaseObject::tablename('meta');
$asset_table = ShoppDatabaseObject::tablename('asset');
sDB::query("INSERT INTO {$meta_table} (parent, context, type, name, value, numeral, sortorder, created, modified)\n\t\t\t\t\t\t\tSELECT parent, context, 'image', 'processing', CONCAT_WS('::', id, name, value, size, properties, LENGTH(data)), '0', sortorder, created, modified FROM {$asset_table} WHERE datatype='image'");
$records = sDB::query("SELECT id, value FROM {$meta_table} WHERE type='image' AND name='processing'", 'array');
foreach ($records as $r) {
list($src, $name, $value, $size, $properties, $datasize) = explode("::", $r->value);
$p = unserialize($properties);
$value = new StdClass();
if (isset($p['width'])) {
$value->width = $p['width'];
}
if (isset($p['height'])) {
$value->height = $p['height'];
}
if (isset($p['alt'])) {
$value->alt = $p['alt'];
}
if (isset($p['title'])) {
$value->title = $p['title'];
}
$value->filename = $name;
if (isset($p['mimetype'])) {
$value->mime = $p['mimetype'];
}
$value->size = $size;
if ($datasize > 0) {
$value->storage = "DBStorage";
$value->uri = $src;
} else {
$value->storage = "FSStorage";
$value->uri = $name;
}
$value = mysqli_real_escape_string(sDB::get()->dbh, serialize($value));
sDB::query("UPDATE {$meta_table} set name='original', value='{$value}' WHERE id={$r->id}");
}
// Update product downloads
$meta_table = ShoppDatabaseObject::tablename('meta');
$asset_table = ShoppDatabaseObject::tablename('asset');
$query = "INSERT INTO {$meta_table} (parent, context, type, name, value, numeral, sortorder, created, modified)\n\t\t\t\t\tSELECT parent, context, 'download', 'processing', CONCAT_WS('::', id, name, value, size, properties, LENGTH(data)), '0', sortorder, created, modified FROM {$asset_table} WHERE datatype='download' AND parent != 0";
sDB::query($query);
$records = sDB::query("SELECT id, value FROM {$meta_table} WHERE type='download' AND name='processing'", 'array');
foreach ($records as $r) {
list($src, $name, $value, $size, $properties, $datasize) = explode("::", $r->value);
$p = unserialize($properties);
$value = new StdClass();
$value->filename = $name;
$value->mime = $p['mimetype'];
$value->size = $size;
if ($datasize > 0) {
$value->storage = "DBStorage";
$value->uri = $src;
} else {
$value->storage = "FSStorage";
$value->uri = $name;
}
$value = mysqli_real_escape_string(sDB::get()->dbh, serialize($value));
sDB::query("UPDATE {$meta_table} set name='{$name}', value='{$value}' WHERE id={$r->id}");
}
// Update promotions
$promo_table = ShoppDatabaseObject::tablename('promo');
$records = sDB::query("UPDATE {$promo_table} SET target='Cart' WHERE scope='Order'", 'array');
$FSStorage = array('path' => array());
// Migrate Asset storage settings
$image_storage = shopp_setting('image_storage_pref');
//.........这里部分代码省略.........
示例4: upschema
/**
* Updates the database schema
*
* @author Jonathan Davis
* @since 1.1
*
* @return void
**/
public function upschema($filename = 'schema.sql')
{
$path = SHOPP_PATH . '/core/schema';
$schema = "{$path}/{$filename}";
// Check for the schema definition file
if (!file_exists($schema)) {
$this->error('nodbschema-upgrade');
}
// Test to ensure Shopp can create/drop tables
$testtable = 'shopp_db_permissions_test_' . time();
$tests = array("CREATE TABLE {$testtable} ( id INT )", "DROP TABLE {$testtable}");
foreach ($tests as $testquery) {
$db = sDB::get();
sDB::query($testquery);
$error = mysql_error($db->dbh);
if (!empty($error)) {
$this->error('dbprivileges');
}
}
// Make sure dbDelta() is available
if (!function_exists('dbDelta')) {
require ABSPATH . 'wp-admin/includes/upgrade.php';
}
ob_start();
include $schema;
$schema = ob_get_clean();
// Update the table schema
// Strip SQL comments
$schema = preg_replace('/--\\s?(.*?)\\n/', "\n", $schema);
$tables = preg_replace('/;\\s+/', ';', $schema);
ob_start();
// Suppress dbDelta errors
$changes = dbDelta($tables);
ob_end_clean();
shopp_set_setting('db_updates', $changes);
}