我需要两个复合主键,只有一个应该是AUTO INCREMENT我到目前为止尝试的:
// first try
Schema::create("kitchen", function($table) {
$table->increments('id');
$table->integer('restaurant_id');
$table->primary(array('id', 'restaurant_id'));
$table->string('name');
});
// second try
Schema::create("kitchen", function($table) {
$table->increments('id');
$table->integer('restaurant_id');
$table->primary('restaurant_id');
$table->string('name');
});
Run Code Online (Sandbox Code Playgroud)
没有用.错误信息:
[Exception]kitchen restaurant_id
SQLSTATE[42000]: Syntax error or access violation: 1068 Multiple primary ke
y defined (SQL: alter tableadd primary key kitchen_restaurant_id
_primary()) (Bindings: array (
))
没有Schema构建器的解决方案:首先,我需要添加两个复合主键,然后我需要创建一个,AUTO INCREMENT但我认为Schema构建器不能这样做.
注意:我可以用SQL做到这一点,我的意思是没有问题
有什么建议?
摘要:
我需要的是;
http://oi39.tinypic.com/es91ft.jpg
与Schema建设者
我有一个表调用follow,这是表结构:
- follower_id
- following_id
- when // timestamp
Run Code Online (Sandbox Code Playgroud)
这些是我执行的SQL查询:
SELECT * FROM follow WHERE follower_id = ? ORDER BY when LIMIT 0,20
SELECT * FROM follow WHERE following_id = ? ORDER BY when LIMIT 0,20
SELECT * FROM follow WHERE follower_id = ?
SELECT * FROM follow WHERE following_id = ?
Run Code Online (Sandbox Code Playgroud)
这些是我的索引:
follower_id, when
following_id, when
follower_id
following_id
Run Code Online (Sandbox Code Playgroud)
这种方法是真的吗?并且在DB中具有此数量(或多于此数量)的索引是否有任何缺点?
看起来垃圾收集器不pop从dict()python 2.7中收集值'd (没有尝试python 3).这是一个例子:
a = dict()
# fill the memory (dict)
for i in xrange(0, 9999999):
a[i] = i
# Memory usage is about 600 MB
# try to free the memory
for i in xrange(0, 9999999):
a.pop(i)
# print the dict and see it is empty
print "%r" % a
# prints: {}
# Memory usage is about 600 MB
import copy
a = copy.copy(a)
# Memory usage decreased to about 200 MB
import …Run Code Online (Sandbox Code Playgroud) 目前我正在使用Laravel 4开发应用程序.我安装了探查器以查看有关我的应用程序的统计信息.这是截图:


您如何看待我的mac和服务器之间的这种差异?
php ×2
database ×1
dictionary ×1
indexing ×1
laravel ×1
laravel-4 ×1
memory ×1
memory-leaks ×1
mysql ×1
python ×1