本文整理汇总了PHP中Illuminate\Database\Capsule\Manager::table方法的典型用法代码示例。如果您正苦于以下问题:PHP Manager::table方法的具体用法?PHP Manager::table怎么用?PHP Manager::table使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Capsule\Manager
的用法示例。
在下文中一共展示了Manager::table方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_sessions_sweep_when_hits_lottery
public function test_sessions_sweep_when_hits_lottery()
{
$config = ['sessions.driver' => 'database'];
$this->dispatch($config);
$rec = $this->capsule->getConnection()->table('sessions')->get();
$this->assertSame(1, count($rec));
$config['sessions.lifetime'] = 0;
$config['sessions.lottery'] = [1, 1];
// 100% hits
$this->dispatch($config);
$rec = $this->capsule->table('sessions')->get();
$this->assertEmpty($rec);
}
示例2: validateUnique
private function validateUnique($item, $value, $parameter)
{
$results = DB::table($parameter)->where($item, '=', $value)->get();
if (sizeof($results) > 0) {
$this->errors[] = $item . ' already exists on this system.';
}
}
示例3: seedData
protected function seedData()
{
$faker = $this->getFaker();
for ($i = 0; $i < $this->count; $i++) {
DB::table('tests')->insert(['title' => $faker->title, 'seq' => $i + 1, 'created_at' => $faker->dateTime(), 'updated_at' => $faker->dateTime()]);
}
}
示例4: acceptFriendRequest
public function acceptFriendRequest($token, $requestId)
{
$user = new User();
$meId = $user->getMeId($token);
try {
$requestData = Capsule::table('friendrequests')->select('userFrom', 'userTo')->where('id', $requestId)->first();
if ($requestData->userFrom == $meId) {
$newFriendId = $requestData->userTo;
} else {
$newFriendId = $requestData->userFrom;
}
} catch (\Exception $e) {
throw new \Exception('Wystąpił błąd przy pobieraniu przyjaciół');
}
if ($user->isUserMyFriend($newFriendId, $token)) {
throw new \Exception('Ten użytkownik jest już Twoim znajomym');
}
try {
Capsule::table('friendrequests')->where('id', $requestId)->where('userFrom', $meId)->orWhere('userTo', $meId)->where('accepted', 0)->update(array('accepted' => 1));
Capsule::table('friends')->insert(array('userA' => $meId, 'userB' => $newFriendId));
} catch (\Exception $e) {
throw new \Exception('Wystąpił błąd przy pobieraniu przyjaciół');
}
$newFriendData = $user->getUser($newFriendId, $token);
return $newFriendData;
}
示例5: queryBuilder
/**
* For raw array fetching. Must be static, otherwise PHP gets confused about where to find the table_id.
*/
public static function queryBuilder()
{
// Set query builder to fetch result sets as associative arrays (instead of creating stdClass objects)
Capsule::connection()->setFetchMode(\PDO::FETCH_ASSOC);
$table = Database::getSchemaTable(static::$_table_id)->name;
return Capsule::table($table);
}
示例6: storeFull
protected function storeFull($json)
{
$categories = json_decode($json, true);
// grab categories from the database
$dbCategories = collect(DB::table('categories')->get(['cSlug']))->keyBy('cSlug')->toArray();
// grab an array of columns in the categories table
$columns = DB::select('select COLUMN_NAME as `column` from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = \'fmtc_categories\'');
// set the counters for reporting
$insertCount = 0;
$removeCount = 0;
// walk through the categories from a merchant feed
$jsonCategoryIds = [];
foreach ($categories as $category) {
// is the category missing from the database?
if (!isset($dbCategories[$category['cSlug']])) {
// insert it (this is faster than building an insert queue and bulk inserting)
DB::table('categories')->insert($this->formatForInsertion($category, $columns));
$insertCount++;
}
// collect an array of ids to aid in the remove queue
$jsonCategoryIds[] = $category['cSlug'];
}
// remove old categories showing up in the database but not in the new merchant feed.
$removeQueue = array_diff(array_keys($dbCategories), $jsonCategoryIds);
$removeCount = count($removeQueue);
foreach ($removeQueue as $categoryId) {
DB::table('categories')->where('cSlug', $categoryId)->delete();
}
//---- debugging
// debug($removeCount . ' removed');
// debug($insertCount . ' inserted');
//-----
return true;
}
示例7: testSerialize
public function testSerialize()
{
$eloquentDriver = new EloquentDriver();
$output = $eloquentDriver->serialize(Capsule::table('users')->find(1));
$expected = array('@type' => 'stdClass', 'id' => array('@scalar' => 'string', '@value' => '1'), 'account_manager_id' => array('@scalar' => 'string', '@value' => '1'), 'username' => array('@scalar' => 'string', '@value' => 'Nil'), 'password' => array('@scalar' => 'string', '@value' => 'password'), 'email' => array('@scalar' => 'string', '@value' => 'test@example.com'), 'created_at' => array('@scalar' => 'string', '@value' => '2016-01-13 00:06:16'), 'updated_at' => array('@scalar' => 'string', '@value' => '2016-01-13 00:06:16'), 'deleted_at' => array('@scalar' => 'NULL', '@value' => null));
$this->assertEquals($expected, $output);
}
示例8: seedData
protected function seedData()
{
$faker = $this->getFaker();
for ($i = 1; $i <= $this->count; $i++) {
DB::table('tests')->insert(['title' => $faker->title, 'seq' => $i, 'created_at' => $i > 5 ? (new DateTime('2005-01-01'))->format('Y-m-d H:i:s') : (new DateTime('1998-01-01'))->format('Y-m-d H:i:s'), 'updated_at' => $faker->dateTime()]);
}
}
示例9: seeInDatabase
/**
* Check to see some data in the database
*/
protected function seeInDatabase($table, $data)
{
$conditions = [];
foreach ($data as $key => $value) {
$conditions[] = [$key, $value];
}
$this->assertTrue(DB::table($table)->where($conditions)->count() > 0);
}
示例10: getBySearch
public function getBySearch($search)
{
$networks = DB::table('networks')->where(function ($query) use($search) {
$search = '%' . $search . '%';
$query->where('cSlug', 'like', $search)->orWhere('aCountries', 'like', $search)->orWhere('cName', 'like', $search);
})->get();
return $networks;
}
示例11: formatDealForReturn
protected function formatDealForReturn($deal)
{
// attach it's categories
$deal->aCategories = DB::table('deals_categories')->where('deals_categories.nCouponID', $id)->join('categories', 'categories.cSlug', '=', 'deals_categories.cCategorySlug')->get();
// attach it's types
$deal->aTypes = DB::table('deals_types')->where('deals_types.nCouponID', $id)->join('types', 'types.cSlug', '=', 'deals_types.cTypeSlug')->get();
return $deal;
}
示例12: run
public function run()
{
DB::table('posts')->delete();
Post::unguard();
Post::create(['id' => 1, 'title' => 'First post', 'body' => 'This is the first post!']);
Post::create(['id' => 2, 'title' => 'Second post', 'body' => 'This is the second post!']);
Post::reguard();
}
示例13: getBySearch
public function getBySearch($search)
{
$merchants = DB::table('merchants')->where(function ($query) use($search) {
$search = '%' . $search . '%';
$query->where('nMerchantID', 'like', $search)->orWhere('nMasterMerchantID', 'like', $search)->orWhere('cName', 'like', $search);
})->get();
return $merchants;
}
示例14: getBySearch
public function getBySearch($search)
{
$types = DB::table('types')->where(function ($query) use($search) {
$search = '%' . $search . '%';
$query->where('cSlug', 'like', $search)->orWhere('cName', 'like', $search);
})->get();
return $types;
}
示例15: gen
public static function gen()
{
$id = Capsule::table('uid')->insertGetId(array());
if (!$id) {
throw new Exception("Could not generate UID!");
}
return $id;
}