public static function register($kvs) { extract($kvs); $type = 'customer'; Pdb::insert(array('name' => $username, 'password' => md5($password), 'type' => $type, 'realname' => $realname, 'phone' => $phone, 'email' => $email, 'create_time=NOW()' => null), self::$table); return new self(Pdb::lastInsertId()); }
public function createFromCart(Cart $cart) { // but big order need customer or something else?? Pdb::insert(array('id=id' => null), self::$table); $id = Pdb::lastInsertId(); foreach ($cart->orders() as $order) { Pdb::insert(array('big' => $id, 'small' => $order->id), 'big_to_small_order'); $order->submit(); } }
public static function create($info) { // 这里竟然没有address $user_info = array('username' => i($info['username']), 'password' => i($info['password']), 'realname' => i($info['realname']), 'phone' => i($info['phone']), 'email' => i($info['email']), 'create_time=NOW()' => null); $user = User::register($user_info); // new an account $account = Account::create(); Pdb::insert(array('user' => $user->id, 'account' => $account->id, 'qq' => i($info['qq']), 'remark' => i($info['remark']), 'state' => i($info['adopted']) ? 'Adopted' : 'ToBeAdopted'), self::$table); return new self(Pdb::lastInsertId()); }
public function createAdmin($opts) { Pdb::insert(array('name' => $opts['username'], 'password' => md5($opts['password']), 'type' => 'Admin', 'create_time=NOW()' => null), User::$table); return new Admin(Pdb::lastInsertId()); }
public static function add($info) { Pdb::insert(array('weight' => $info['weight']), self::$table); return new self(Pdb::lastInsertId()); }
public static function create() { Pdb::insert(array('remain' => 0, 'done' => 0, 'undone' => 0), Account::$table); return new self(Pdb::lastInsertId()); }
public static function addCustomized($info) { Pdb::insert(array_merge($info, array('is_customized' => 1)), self::$table); return new self(Pdb::lastInsertId()); }
public static function create($info = array()) { $self = get_called_class(); Pdb::insert($info, $self::$table); return new self(Pdb::lastInsertId()); }
$realname = '小池'; $phone = '13711231212'; $email = '*****@*****.**'; $info = compact('username', 'password', 'realname', 'phone', 'email'); $customer = Customer::create($info); test(1, 1, array('name' => 'register Customer, db')); begin_test(); test(User::check($username, $password), true, array('name' => 'User::check($username, $password)')); begin_test(); $username = '******'; $password = '******'; $user = User::getByName('root'); $superadmin = $user->instance(); $admin = $superadmin->createAdmin(compact('username', 'password')); $ideal_arr = array('name' => $username, 'password' => md5($password), 'type' => 'Admin'); $id = Pdb::lastInsertId(); $real_arr = Pdb::fetchRow('name, password, type', User::$table, array('id=?' => $id)); test($real_arr, $ideal_arr, array('name' => 'Super Admin create Admin, db')); begin_test(); $prd_types = Product::types(); $info = array('name' => '唯爱心形群镶女戒_test', 'type' => reset(array_keys($prd_types)), 'material' => json_encode(array('PT950', '白18K金', '黄18K金', '红18K金')), 'rabbet_start' => '0.30', 'rabbet_end' => '0.60', 'weight' => 9, 'small_stone' => 3, 'st_weight' => 2.1, 'images' => array('400' => array('/test/static/img/i400-1.jpg', '/test/static/img/i400-2.jpg', '/test/static/img/i400-3.jpg'), 'thumb' => array('/test/static/img/i80-1.jpg', '/test/static/img/i80-2.jpg', '/test/static/img/i80-3.jpg'))); $product = Product::create($info); test(1, 1, array('name' => 'Admin post Product, db')); begin_test(); $address = $customer->defaultAddress(); $address->edit(array('name' => '小池', 'phone' => '14722320989', 'detail' => '深圳罗湖区田贝')); test(1, 1, array('name' => 'edit Address')); begin_test(); $cart = $customer->cart(); test(+$cart->count(), 2, array('name' => 'Cart count()')); begin_test();
public static function create($info) { Pdb::insert($info, self::$table); return new self(Pdb::lastInsertId()); }
public function postProduct($info) { Pdb::insert(array_merge($info, array('post_time=NOW()' => null)), Product::$table); return new Product(Pdb::lastInsertId()); }