本文整理汇总了PHP中Model_Users::getPrefixDB方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_Users::getPrefixDB方法的具体用法?PHP Model_Users::getPrefixDB怎么用?PHP Model_Users::getPrefixDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model_Users
的用法示例。
在下文中一共展示了Model_Users::getPrefixDB方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createUser
public static function createUser($data)
{
$db = JO_Db::getDefaultAdapter();
if (!$data['username'] || Model_Users::getByUsername($data['username'])) {
return false;
}
if (!$data['email'] || Model_Users::getByEmail($data['email'])) {
return false;
}
$db->insert(Model_Users::getPrefixDB() . 'users', array('username' => $data['username'], 'password' => $data['password'], 'email' => $data['email'], 'firstname' => $data['firstname'], 'lastname' => $data['lastname'], 'firmname' => $data['firmname'], 'profile_title' => $data['profile_title'], 'profile_desc' => $data['profile_desc'], 'register_datetime' => $data['register_datetime'], 'status' => 'activate'));
$user_id = $db->lastInsertId();
if ($user_id) {
$upload_path = BASE_PATH . '/uploads';
$user_path = '/users/' . JO_Date::getInstance($data['register_datetime'], 'yy/mm/')->toString() . $user_id . '/';
$upload_path .= $user_path;
if ($data['avatar'] && @getimagesize($data['avatar'])) {
$name = basename($data['avatar']);
if (copy($data['avatar'], $upload_path . $name)) {
$db->update('users', array('avatar' => $user_path . $name), array('user_id' => $user_id));
}
}
if ($data['homeimage'] && @getimagesize($data['homeimage'])) {
$name = basename($data['homeimage']);
if (copy($data['homeimage'], $upload_path . $name)) {
$db->update('users', array('homeimage' => $user_path . $name), array('user_id' => $user_id));
}
}
return Model_Users::getUser($user_id);
}
}
示例2: getPercentRow
public function getPercentRow($user)
{
$db = JO_Db::getDefaultAdapter();
$query = $db->select()->from(Model_Users::getPrefixDB() . 'users', 'commission_percent')->where('user_id= ?', $user['user_id'])->limit(1, 0);
$user_data = $db->fetchRow($query);
if ($user_data && round($user_data['commission_percent']) > 0) {
return array('percent' => floatval($user_data['commission_percent']), 'to' => 0);
}
$no_exclusive_author_percent = 30;
if (JO_Registry::get('no_exclusive_author_percent')) {
$no_exclusive_author_percent = (int) JO_Registry::get('no_exclusive_author_percent');
}
$exclusive_author_percent = 40;
if (JO_Registry::get('exclusive_author_percent')) {
$exclusive_author_percent = (int) JO_Registry::get('exclusive_author_percent');
}
if ($user['exclusive_author'] == 'false') {
$percent = array('percent' => $no_exclusive_author_percent, 'to' => 0);
} else {
$query = $db->select()->from(Model_Users::getPrefixDB() . 'percents')->where("`from` <= ? AND (`to` > ? OR `to` = 0)", $user['sold']);
$data = $db->fetchRow($query);
if (count($data) == 0) {
$percent = array('percent' => $exclusive_author_percent, 'to' => 0);
} else {
$percent = $data;
}
}
return $percent;
}
示例3: getWithdraws
public static function getWithdraws($from, $to)
{
$db = JO_Db::getDefaultAdapter();
$query = $db->select()->from(Model_Users::getPrefixDB() . 'withdraw')->where("`paid` = 'true'")->order('paid_datetime');
$d = explode('-', $from);
if (count($d) == 3 && checkdate($d[1], $d[2], $d[0])) {
$query->where('`paid_datetime` >= ?', $from);
}
$d = explode('-', $to);
if (count($d) == 3 && checkdate($d[1], $d[2], $d[0])) {
$query->where('`paid_datetime` <= ?', $to);
}
$results = $db->fetchAll($query);
$return = array();
if ($results) {
foreach ($results as $result) {
$date = explode(' ', $result['paid_datetime']);
$date = $date[0];
if (!isset($return[$date]['amount'])) {
$return[$date]['amount'] = 0;
}
$return[$date]['amount'] += $result['amount'];
}
}
return $return;
}
示例4: add
public static function add($action, $transactionID, $userID = 0)
{
if ($userID == 0) {
$userID = JO_Session::get('user_id');
}
$db = JO_Db::getDefaultAdapter();
$db->insert(Model_Users::getPrefixDB() . 'history', array('user_id' => $userID, 'action' => $action, 'transaction_id' => $transactionID, 'datetime' => new JO_Db_Expr('NOW()')));
return true;
}
示例5: getTotal
public static function getTotal($where = '')
{
$db = JO_Db::getDefaultAdapter();
$query = $db->select()->from('items_comments', 'COUNT(id)')->joinLeft(Model_Users::getPrefixDB() . 'users', 'items_comments.user_id = users.user_id', array())->limit(1);
if ($where) {
$query->where($where);
}
return $db->fetchOne($query);
}
示例6: getTotalUserBalanceByType
public static function getTotalUserBalanceByType($id)
{
$db = JO_Db::getDefaultAdapter();
$query = $db->select()->from(Model_Users::getPrefixDB() . 'deposit', new JO_Db_Expr("SUM(IF(`paid` = 'true', 1, 0)) AS `paid`,SUM(IF(`paid` = 'false', 1, 0)) AS `not_paid`"))->where('user_id = ?', (int) $id)->group('user_id');
$result = $db->fetchRow($query);
if (!$result) {
return array('paid' => 0, 'not_paid' => 0);
}
return $result;
}
示例7: getCollections
public static function getCollections($data = array())
{
$db = JO_Db::getDefaultAdapter();
$query = $db->select()->from('collections')->joinLeft(Model_Users::getPrefixDB() . 'users', 'collections.user_id = users.user_id', 'username')->order('id DESC');
if (isset($data['start']) && isset($data['limit'])) {
if ($data['start'] < 0) {
$data['start'] = 0;
}
$query->limit($data['limit'], $data['start']);
}
return $db->fetchAll($query);
}
示例8: change_deposit
public static function change_deposit($id)
{
$db = JO_Db::getDefaultAdapter();
$row = $db->fetchRow('SELECT * FROM deposit WHERE id = ' . $db->quote($id));
if ($row) {
if ($row['paid'] === 'true') {
return;
}
$db->update(Model_Users::getPrefixDB() . 'users', array('deposit' => new JO_Db_Expr('deposit + ' . $row['deposit']), 'total' => new JO_Db_Expr('total + ' . $row['deposit'])), array('user_id = ?' => (int) $row['user_id']));
$db->update(Model_Users::getPrefixDB() . 'deposit', array('paid' => 'true', 'added' => 'true'), array('id = ?' => (int) $id));
}
}
示例9: getAllFront
public function getAllFront()
{
$db = JO_Db::getDefaultAdapter();
$query = $db->select()->from(Model_Users::getPrefixDB() . 'badges')->where('visible = ?', 'true');
$return = array();
foreach ($db->fetchAll($query) as $d) {
if ($d['type'] == 'system') {
$return[$d['type']][$d['sys_key']] = array('name' => $d['name'], 'photo' => $d['photo']);
} elseif ($d['type'] == 'other') {
$return[$d['type']][$d['id']] = array('name' => $d['name'], 'photo' => $d['photo']);
} else {
if (strpos($d['from'], '+') !== false) {
$key = (int) $d['from'] . '-2147483646';
} else {
$key = $d['from'] . '-' . $d['to'];
}
$return[$d['type']][$key] = array('name' => $d['name'], 'photo' => $d['photo']);
}
}
return $return;
}
示例10: deleteItem
public static function deleteItem($id, $message = '')
{
$db = JO_Db::getDefaultAdapter();
$info = self::getItem($id);
if (!$info) {
return;
}
$path = BASE_PATH . '/uploads/items/' . JO_Date::getInstance($info['datetime'], 'yy/mm/', true)->toString() . $id . '/';
self::unlink($path);
$db->delete('items', array('id = ?' => (int) $id));
$db->delete('items_attributes', array('item_id = ?' => (int) $id));
$db->delete('items_collections', array('item_id = ?' => (int) $id));
$db->delete('items_comments', array('item_id = ?' => (int) $id));
$db->delete('items_faqs', array('item_id = ?' => (int) $id));
$db->delete('items_rates', array('item_id = ?' => (int) $id));
$db->delete('items_tags', array('item_id = ?' => (int) $id));
$db->delete('items_to_category', array('item_id = ?' => (int) $id));
$db->update(Model_Users::getPrefixDB() . 'users', array('items' => new JO_Db_Expr('items - 1')), array('user_id = ?' => $info['user_id']));
/////////// send email
$request = JO_Request::getInstance();
$translate = JO_Translate::getInstance();
$not_template = Model_Notificationtemplates::get('delete_item');
$mail = new JO_Mail();
if (JO_Registry::get('mail_smtp')) {
$mail->setSMTPParams(JO_Registry::forceGet('mail_smtp_host'), JO_Registry::forceGet('mail_smtp_port'), JO_Registry::forceGet('mail_smtp_user'), JO_Registry::forceGet('mail_smtp_password'));
}
$mail->setFrom('no-reply@' . $request->getDomain());
if ($not_template) {
$user_info = Model_Users::getUser($info['user_id']);
$title = $not_template['title'];
$html = html_entity_decode($not_template['template'], ENT_QUOTES, 'utf-8');
$html = str_replace('{USERNAME}', $user_info['username'], $html);
$html = str_replace('{ITEM}', $info['name'], $html);
$html = str_replace('{MESSAGE}', $message, $html);
} else {
$title = "[" . $request->getDomain() . "] " . $info['name'];
$html = nl2br($translate->translate('Item is deleted'));
}
$mail->setSubject($title);
$mail->setHTML($html);
$result = $mail->send(array($user_info['email']), JO_Registry::get('mail_smtp') ? 'smtp' : 'mail');
unset($mail);
//////////////////////
self::deleteItemUpdate($id);
self::unlink(BASE_PATH . '/uploads/items/' . JO_Date::getInstance($info['datetime'], 'yy/mm/', true)->toString() . $id . '/');
self::unlink(BASE_PATH . '/uploads/cache/items/' . JO_Date::getInstance($info['datetime'], 'yy/mm/', true)->toString() . $id . '/');
// $info = self::getItemUpdate($id);
// if(!$info) {
// return;
// }
//
// $db->delete('temp_items', array('item_id = ?' => (int)$id));
// $db->delete('temp_items_tags', array('item_id = ?' => (int)$id));
}
示例11: deleteUserGroup
public static function deleteUserGroup($group_id)
{
$db = JO_Db::getDefaultAdapter();
return $db->delete(Model_Users::getPrefixDB() . 'user_groups', array('ug_id = ?' => (int) $group_id));
}
示例12: CountUsers2
public static function CountUsers2($whereQuery = '')
{
$db = JO_Db::getDefaultAdapter();
if ($whereQuery != '') {
$whereQuery = " WHERE " . $whereQuery;
}
return $db->query("\r\r\n\t\t\tSELECT COUNT(user_id)\r\r\n\t\t\tFROM " . Model_Users::getPrefixDB() . "`users`\r\r\n\t\t\t{$whereQuery}\r\r\n\t\t")->fetchColumn();
}
示例13: delete
public function delete($item_id)
{
$db = JO_Db::getDefaultAdapter();
$info = self::get($item_id);
if (!$info) {
return;
}
$db->delete('items', array('id=?' => $item_id));
$db->delete('temp_items', array('id=?' => $item_id));
$db->delete('temp_items_tags', array('item_id=?' => $item_id));
$db->delete('items_attributes', array('item_id=?' => $item_id));
$db->delete('items_collections', array('item_id=?' => $item_id));
$db->delete('items_comments', array('item_id=?' => $item_id));
$db->delete('items_faqs', array('item_id=?' => $item_id));
$db->delete('items_rates', array('item_id=?' => $item_id));
$db->delete('items_tags', array('item_id=?' => $item_id));
$db->delete('items_to_category', array('item_id=?' => $item_id));
$db->update(Model_Users::getPrefixDB() . 'users', array('items' => new JO_Db_Expr('items - 1')), array('user_id = ?' => $info['user_id']));
self::unlink(BASE_PATH . '/uploads/items/' . JO_Date::getInstance($info['datetime'], 'yy/mm/', true)->toString() . $item_id . '/');
self::unlink(BASE_PATH . '/uploads/cache/items/' . JO_Date::getInstance($info['datetime'], 'yy/mm/', true)->toString() . $item_id . '/');
}
示例14: buy
public function buy($item, $price, $extended = 'false')
{
$you = Model_Users::getUser(JO_Session::get('user_id'));
$deposit = 0;
$earning = 0;
if ($you['deposit'] > $price) {
$deposit = $price;
} else {
$deposit = $you['deposit'];
$earning = floatval($price) - floatval($you['deposit']);
}
$db = JO_Db::getDefaultAdapter();
$db->update(Model_Users::getPrefixDB() . 'users', array('deposit' => new JO_Db_Expr('deposit - ' . floatval($deposit)), 'earning' => new JO_Db_Expr('earning - ' . floatval($earning)), 'total' => new JO_Db_Expr('total - ' . floatval($price))), array('user_id =?' => $you['user_id']));
JO_Session::set('deposit', floatval(JO_Session::get('deposit')) - floatval($deposit));
JO_Session::set('earning', floatval(JO_Session::get('earning')) - floatval($earning));
JO_Session::set('total', floatval(JO_Session::get('total')) - floatval($price));
#ADD PRICE TO OWNER USER
$user = Model_Users::getUser($item['user_id']);
$percent = Model_Percentes::getPercentRow($user);
$percent = $percent['percent'];
$receiveMoney = floatval($price) * floatval($percent) / 100;
$db->update(Model_Users::getPrefixDB() . 'users', array('earning' => new JO_Db_Expr('earning+' . floatval($receiveMoney)), 'total' => new JO_Db_Expr('total + ' . floatval($receiveMoney)), 'sold' => new JO_Db_Expr('sold + ' . floatval($price)), 'sales' => new JO_Db_Expr('sales+1')), array('user_id =?' => $user['user_id']));
#ADD ORDER
$currency = WM_Currency::getCurrency();
$db->insert('orders', array('user_id' => (int) JO_Session::get('user_id'), 'owner_id' => (int) $item['user_id'], 'item_id' => (int) $item['id'], 'item_name' => $item['name'], 'price' => (double) $price, 'datetime' => new JO_Db_Expr('NOW()'), 'receive' => $receiveMoney, 'paid' => 'true', 'paid_datetime' => new JO_Db_Expr('NOW()'), 'extended' => $extended, 'type' => 'buy', 'currency_code' => $currency['code'], 'currency_value' => $currency['value'], 'module' => $item['module']));
$order_id = $db->lastInsertId();
if ($order_id && $you['referal_id'] != '0') {
self::referalMoney(array('order_id' => $order_id, 'price' => $price, 'user_id' => JO_Session::get('user_id'), 'owner_id' => $item['user_id'], 'item_id' => $item['id'], 'item_name' => $item['name'], 'currency_code' => $currency['code'], 'currency_value' => $currency['value']), $you);
}
$db->update(Model_Users::getPrefixDB() . 'users', array('buy' => new JO_Db_Expr('buy+1')), array('user_id =?' => JO_Session::get('user_id')));
#UPDATE ITEM
$toadd = array('sales' => new JO_Db_Expr('sales+1'), 'earning' => new JO_Db_Expr('earning+' . $price));
if ($extended == 'true') {
$toadd['status'] = 'extended_buy';
}
$db->update('items', $toadd, array('id = ?' => $item['id']));
return true;
}
示例15: referalMoney
public function referalMoney($row, $you)
{
$db = JO_Db::getDefaultAdapter();
$totals = Model_Users::getTotalReferals($you['user_id'], $you['referal_id']);
if ((int) JO_Registry::get('referal_sum') && $totals + 1 > (int) JO_Registry::get('referal_sum')) {
$db->update(Model_Users::getPrefixDB() . 'users', array('referal_id' => '0'), array('user_id = ?' => $you['user_id']));
return false;
}
$referalMoney = floatval($row['price']) * (int) JO_Registry::get('referal_percent') / 100;
$db->update(Model_Users::getPrefixDB() . 'users', array('earnings' => new JO_Db_Expr('earnings+' . $referalMoney), 'total' => new JO_Db_Expr('total+' . $referalMoney), 'referal_money' => new JO_Db_Expr('referal_money' + $referalMoney)), array('user_id = ?' => $you['user_id']));
$db->insert('orders', array('order_id' => $row['id'], 'user_id' => $row['user_id'], 'owner_id' => $row['owner_id'], 'item_id' => $row['item_id'], 'item_name' => $row['item_name'], 'price' => $row['price'], 'datetime' => new JO_Db_Expr('NOW()'), 'receive' => $referalMoney, 'paid' => 'true', 'paid_datetime' => new JO_Db_Expr('NOW()'), 'type' => 'referal'));
$db->insert(Model_Users::getPrefixDB() . 'users_referals_count', array('user_id' => $you['user_id'], 'referal_id' => $you['referal_id'], 'datetime' => new JO_Db_Expr('NOW()')));
}