Показать сообщение отдельно
  #3 (permalink)  
Старый 21.11.2015, 19:22
Новичок на форуме
Отправить личное сообщение для Alasdair Посмотреть профиль Найти все сообщения от Alasdair
 
Регистрация: 21.11.2015
Сообщений: 5

и планирую его так использовать

Use('User', 'model');


User.findOne({id: 1, username: 'vasya'}, ['id']); // SELECT `id` FROM `user` WHERE id = 1 AND username = vasya ORDER BY id DESC LIMIT 1
User.findOne({}, ['id']); // SELECT `id` FROM `user` WHERE id <> 0 ORDER BY id DESC LIMIT 1
User.findOne({id: 1, username: 'vasya'}); // SELECT * FROM `user` WHERE id = 1 AND username = vasya ORDER BY id DESC LIMIT 1
User.findOne(); // SELECT * FROM `user` WHERE id <> 0 ORDER BY id DESC LIMIT 1

User.findAll({id: 1, username: 'vasya'}, ['id']); // SELECT `id` FROM `user` WHERE id = 1 AND username = vasya
User.findAll({}, ['id']); // SELECT `id` FROM `user` WHERE id <> 0
User.findAll({id: 1, username: 'vasya'}); // SELECT * FROM `user` WHERE id = 1 AND username = vasya
User.findAll(); // SELECT * FROM `user` WHERE id <> 0

User.findBySql('SELECT COUNT(*) FROM user');

User.update({id: 5}, {username: 'dgdfg', email: 'sdfsd@dfgdf.sf'}); // UPDATE user SET username=dgdfg, email=sdfsd@dfgdf.sf WHERE id=5
User.update({id: 5, username: 'aaAAA'}, {username: 'dgdfg', email: 'sdfsd@dfgdf.sf'}); // UPDATE user SET username=dgdfg, email=sdfsd@dfgdf.sf WHERE id=5 AND username=aaAAA

User.count(); // SELECT COUNT(*) FROM user
User.count({id: 5}); // SELECT COUNT(*) FROM user  WHERE id=5

User.deleteAll({id: 4}); // DELETE FROM user WHERE id=4
User.deleteAll({id: 4, 'username': 'user'}); // DELETE FROM user WHERE id=4 AND username=user

User.countGroup({id: [5, 8], sex:[4,7]}); // SELECT id, sex, COUNT(*) FROM user WHERE id=5 OR id=8 OR sex=4 OR sex=7 GROUP BY id, sex
User.countGroup({id: [5, 8], sex:''}); // SELECT id, sex, COUNT(*) FROM user WHERE id=5 OR id=8 GROUP BY id, sex
Ответить с цитированием