Yii Framework Forum: countAllByPK - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

countAllByPK Rate Topic: -----

#1 User is offline   kirs 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 03-August 09

Posted 09 January 2010 - 04:58 PM

I miss function countAllByPK :)
This is useful if you want to paginate items, when you know ids and provide additional criteria.
or what is the right syntax to pass an array to IN SQL condition?
0

#2 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,138
  • Joined: 17-January 09
  • Location:Russia

Posted 09 January 2010 - 06:46 PM

$pks = array(1, 2, 3);
$post = Post::model();
$criteria=$post->getCommandBuilder()->createPkCriteria($post->getTableSchema(), $pks);
$count = $post->count($criteria);

Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users