mysql> create table newsgroup(
-> id integer unsigned NOT NULL AUTO_INCREMENT,
-> creater integer unsigned NOT NULL,
-> coremember integer unsigned DEFAULT NULL,
-> name varchar(300) not null unique,
-> description text,
-> created datetime not null,
-> PRIMARY KEY (id)
-> );
ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
mysql>
Run Code Online (Sandbox Code Playgroud)
我换300了250,没关系.但我真的不明白.
HTTP://localhost/frontend_dev.php/1
为什么上述请求被重定向frontend_dev.php而不是index.php?
我读过.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
# uncomment the following line, if you are having trouble
# getting no_script_name to work
#RewriteBase /
# we skip all files with .something
#RewriteCond %{REQUEST_URI} \..+$
#RewriteCond %{REQUEST_URI} !\.html$
#RewriteRule .* - [L]
# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L] …Run Code Online (Sandbox Code Playgroud) mysql> create table products(id integer unsigned auto_increment primary key);
Query OK, 0 rows affected (0.05 sec)
mysql> CREATE TABLE orders (
-> id integer PRIMARY KEY auto_increment,
-> product_id integer REFERENCES products (id),
-> quantity integer,
-> INDEX product_id_idx (product_id)
-> );
Query OK, 0 rows affected (0.05 sec)
mysql> insert into orders(product_id,quantity) value(1,1);
Query OK, 1 row affected (0.00 sec)
Run Code Online (Sandbox Code Playgroud)
由于产品 1 不存在,该insert语句应该会失败,但实际上不会。
为什么?
删除它们的任何记录都会报告如下错误:
错误1451(23000):无法删除或更新父行:外键约束失败
如何克服这个问题?
我认为它是简单外键关系的别名,但似乎不是。
你能以MySQL为例什么是关联关系?
我猜这意味着多对多关系,是真的吗?
$arr = array(array(array()));
foreach($arr as $subarr)
{
$subarr[] = 1;
}
var_dump($arr);
Run Code Online (Sandbox Code Playgroud)
输出:
array(1) {
[0]=>
array(1) {
[0]=>
array(0) {
}
}
}
Run Code Online (Sandbox Code Playgroud)
但对于对象,它的参考:
class testclass {
}
$arr = array(new testclass());
foreach($arr as $subarr)
{
$subarr->new = 1;
}
var_dump($arr);
Run Code Online (Sandbox Code Playgroud)
输出:
array(1) {
[0]=>
object(testclass)#1 (1) {
["new"]=>
int(1)
}
}
Run Code Online (Sandbox Code Playgroud)
为什么治疗array不同object?
$arr = array($arr1,$arr2,..);
Run Code Online (Sandbox Code Playgroud)
如何搜索$arr以找到具有key1 => 'something',key2 => 'something else'
php ×5
arrays ×2
foreign-keys ×2
mysql ×2
associations ×1
batch-file ×1
constraints ×1
controller ×1
database ×1
loops ×1
object ×1
sql ×1
symfony1 ×1
syntax ×1
windows ×1