本文整理汇总了PHP中ShoppDatabaseObject::dataset方法的典型用法代码示例。如果您正苦于以下问题:PHP ShoppDatabaseObject::dataset方法的具体用法?PHP ShoppDatabaseObject::dataset怎么用?PHP ShoppDatabaseObject::dataset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShoppDatabaseObject
的用法示例。
在下文中一共展示了ShoppDatabaseObject::dataset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: event
/**
* Updates a purchase order with transaction information from order events
*
* @author Jonathan Davis
* @since 1.2
*
* @param OrderEvent $Event The order event passed by the action hook
* @return void
**/
public static function event($Event)
{
$Purchase = $Event->order();
if (!$Purchase) {
shopp_debug('Cannot update. No event order.');
return;
}
// Transaction status is the same as the event, no update needed
if ($Purchase->txnstatus == $Event->name) {
shopp_debug('Transaction status (' . $Purchase->txnstatus . ') for purchase order #' . $Purchase->id . ' is the same as the new event, no update necessary.');
return;
}
$status = false;
$txnid = false;
// Set transaction status from event name
$txnstatus = $Event->name;
if ('refunded' == $txnstatus) {
// Determine if this is fully refunded (previous refunds + this refund amount)
if (empty($Purchase->events)) {
$Purchase->load_events();
}
// Not refunded if less than captured, so don't update txnstatus
if ($Purchase->refunded + $Event->amount < $Purchase->captured) {
$txnstatus = false;
}
}
if ('voided' == $txnstatus) {
// Determine if the transaction has been cancelled
if (empty($Purchase->events)) {
$Purchase->load_events();
}
if ($Purchase->captured) {
$txnstatus = false;
}
// If previously captured, don't mark voided
}
if ('shipped' == $txnstatus) {
$txnstatus = false;
}
// 'shipped' is not a valid txnstatus
// Set order workflow status from status label mapping
$labels = (array) shopp_setting('order_status');
$events = (array) shopp_setting('order_states');
$key = array_search($Event->name, $events);
if (false !== $key && isset($labels[$key])) {
$status = (int) $key;
}
// Set the transaction ID if available
if (isset($Event->txnid) && !empty($Event->txnid)) {
$txnid = $Event->txnid;
}
$updates = compact('txnstatus', 'txnid', 'status');
$updates = array_filter($updates);
$data = sDB::escape($updates);
$data = array_map(create_function('$value', 'return "\'$value\'";'), $data);
$dataset = ShoppDatabaseObject::dataset($data);
if (!empty($dataset)) {
$table = ShoppDatabaseObject::tablename(self::$table);
$query = "UPDATE {$table} SET {$dataset} WHERE id='{$Event->order}' LIMIT 1";
sDB::query($query);
}
$Purchase->updates($updates);
return;
}
示例2: save
public function save()
{
$data = sDB::prepare($this, $this->_map);
$id = $this->{$this->_key};
if (!empty($this->_map)) {
$remap = array_flip($this->_map);
if (isset($remap[$this->_key])) {
$id = $this->{$remap[$this->_key]};
}
}
// Insert new record
$data['modified'] = "'" . current_time('mysql') . "'";
$dataset = ShoppDatabaseObject::dataset($data);
$query = "INSERT {$this->_table} SET {$dataset} ON DUPLICATE KEY UPDATE {$dataset}";
$id = sDB::query($query);
do_action_ref_array('shopp_save_productsummary', array(&$this));
return $id;
}
示例3: save
/**
* Saves the current state of the ShoppDatabaseObject to the database
*
* Intelligently saves a ShoppDatabaseObject, using an UPDATE query when the
* value for the primary key is set, and using an INSERT query when the
* value of the primary key is not set.
*
* @author Jonathan Davis
* @since 1.0
* @version 1.2
*
* @return boolean|int Returns true when UPDATEs are successful; returns an integer with the record ID
**/
public function save()
{
$classhook = strtolower(get_class($this));
$data = sDB::prepare($this, $this->_map);
$id = isset($this->{$this->_key}) ? $this->{$this->_key} : false;
if (!empty($this->_map)) {
$remap = array_flip($this->_map);
if (isset($remap[$this->_key])) {
$id = $this->{$remap[$this->_key]};
}
}
$time = current_time('mysql');
if (isset($data['modified'])) {
$data['modified'] = "'{$time}'";
}
if (empty($id)) {
// Insert new record
if (isset($data['created'])) {
$data['created'] = "'{$time}'";
}
$dataset = ShoppDatabaseObject::dataset($data);
$this->id = sDB::query("INSERT {$this->_table} SET {$dataset}");
do_action_ref_array("shopp_save_{$classhook}", array($this));
do_action_ref_array("shopp_create_{$classhook}", array($this));
return $this->id;
}
// Update record
$dataset = ShoppDatabaseObject::dataset($data);
sDB::query("UPDATE {$this->_table} SET {$dataset} WHERE {$this->_key}='{$id}'");
do_action_ref_array("shopp_save_{$classhook}", array($this));
return true;
}
示例4: update
/**
* Updates the setting in the registry and the database
*
* @since 1.0
*
* @param string $name Name of the setting
* @param mixed $value Value of the setting to update
* @return boolean
**/
public function update($name, $value)
{
if ($this->get($name) === $value) {
return true;
}
$Setting = $this->setting();
$Setting->name = $name;
$Setting->value = sDB::clean($value);
$data = sDB::prepare($Setting);
// Prepare the data for db entry
$dataset = ShoppDatabaseObject::dataset($data);
// Format the data in SQL
$where = array("context='{$Setting->context}'", "type='{$Setting->type}'");
if (!empty($name)) {
$where[] = "name='" . sDB::clean($name) . "'";
}
$where = join(' AND ', $where);
if (sDB::query("UPDATE {$this->_table} SET {$dataset} WHERE {$where}")) {
$this->registry[$name] = $this->restore($value);
} else {
return false;
}
return true;
}