本文整理汇总了PHP中PhoneNumber::select方法的典型用法代码示例。如果您正苦于以下问题:PHP PhoneNumber::select方法的具体用法?PHP PhoneNumber::select怎么用?PHP PhoneNumber::select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhoneNumber
的用法示例。
在下文中一共展示了PhoneNumber::select方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: User
$user = new User($id);
OrmTest::assertTrue('Testing fetching object by id on new object.', $user->getName() === $name);
$users = User::select('1=?', 1);
OrmTest::assertTrue('Testing fetching objects by select() method.', count($users) === 4 and $users->current()->getName() !== '');
OrmTest::assertTrue('Testing array access by id of results set.', $users[$id]->getName() !== '');
$users = User::find(array('active' => 1));
OrmTest::assertTrue('Testing fetching objects by find() method.', count($users) === 4 and $users->current()->getName() !== '');
$user = User::one(array('name' => 'Jason'));
OrmTest::assertTrue('Testing fetching object by one() method.', $user->getName() === 'Jason');
$phone = $user->create(new PhoneNumber(array('type' => 'home', 'number' => '607-000-0000')));
OrmTest::assertTrue('Testing create new object through create() method.', $phone instanceof PhoneNumber and $phone->getUserId() === $user->getId());
foreach (array(111, 222, 333, 444, 555) as $prefix) {
$user->create(new PhoneNumber(array('type' => 'home', 'number' => '607-' . $prefix . '-0000', 'location' => null)))->save();
}
OrmTest::assertTrue('Loading records to test method appication to entire results set.', true);
PhoneNumber::select('`number` like "607%" and `location` IS NULL order by `number`')->setLocation('Ithaca, NY')->setType('Cell Phone')->save();
$phones = PhoneNumber::find(array('location' => 'Ithaca, NY', 'type' => 'Cell Phone'));
OrmTest::assertTrue('Checking to see if method application applied correctly.', count($phones) === 5);
OrmTest::assertTrue('Testing getRelationClassName style magic method (singular).', $user->getPhoneNumber()->getLocation() === 'Ithaca, NY');
OrmTest::assertTrue('Testing getRelationClassName style magic method (list) .', count($user->getPhoneNumber(true)) === 5 and $user->getPhoneNumber(true)->current()->getLocation() === 'Ithaca, NY');
OrmTest::assertTrue('Testing getRelationClassName style magic method (custom) .', $user->getPhoneNumber('`number` like ?', "%111%")->current()->getNumber() === '607-111-0000');
$post = $user->create(new Post(array('title' => 'test post', 'body' => "I ain't got no body..")));
$post->addMeta(array('background' => 'blue', 'border' => '1px solid grey'));
$post->setMeta('border', '2px solid white');
OrmTest::assertTrue('Testing addMeta(), setMeta() and getMeta() methods.', $post->getMeta('background') === 'blue' and $post->getMeta('border') === '2px solid white');
$post->save();
$post = $user->getPost();
OrmTest::assertTrue('Testing getMeta() methods after save().', $post->getMeta('background') === 'blue' and $post->getMeta('border') === '2px solid white');
$post->delete();
OrmTest::assertTrue('Testing delete() method on an object.', count($user->getPost(true)) === 0);
OrmTest::assertTrue('Testing complete. (' . OrmTest::$fails . ' fails)', !OrmTest::$fails);