当我为约会网站设计MySQL数据库时,我怀疑如何存储引用的数据.目前,该数据库有33个表,并且有近32个不同的字段需要引用.我们还必须考虑许多这些要素需要翻译.
在阅读了几个意见后,我几乎不喜欢使用enum:
CREATE TABLE profile (
'user_id' INT NOT NULL,
...
'relationship_status' ENUM('Single','Married') NOT NULL,
...
);
Run Code Online (Sandbox Code Playgroud)
通常我会使用如下参考表:
CREATE TABLE profile (
'user_id' INT NOT NULL,
...
'relationship_status_id' INT NOT NULL,
...
);
CREATE TABLE relationship_status (
'id' INT NOT NULL,
'name' VARCHAR(45) NOT NULL,
PRIMARY KEY ('id')
);
Run Code Online (Sandbox Code Playgroud)
但是创建32个表可能会被过度杀死所以我正在考虑用PHP编写代码:
class RelationshipStatusLookUp{
const SINGLE = 1;
const MARRIED = 2;
public static function getLabel($status){
if($status == self::SINGLE)
return 'Single';
if($status == self::MARRIED) …Run Code Online (Sandbox Code Playgroud) 我想知道这种结构在HTML5中是否在语义上是正确的.
<html>
<head></head>
<body>
<aside>
<header>
<h1></h1>
</header>
<div>
</div>
</aside>
<section id="content">
</section>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我想要的是一个左侧栏占据屏幕的30%,标识和下面的一些东西,然后内容占据右侧的另外70%.
非常感谢.
使用这样的查询:
SELECT * FROM (
SELECT * FROM message ORDER BY added_on DESC
) as m WHERE receiver_id = 2 GROUP BY sender_id ORDER BY priority_id DESC;
Run Code Online (Sandbox Code Playgroud)
我知道如何使用findAllBySql:
$this->findAllBySql(
'SELECT * FROM (
SELECT * FROM message ORDER BY added_on DESC
) as m WHERE receiver_id = :receiverId
GROUP BY sender_id
ORDER BY priority_id DESC',
array('receiverId' => $userId));
Run Code Online (Sandbox Code Playgroud)
但我想知道是否有任何方法使用CDbCriteria执行此操作导致以下代码,当然,不起作用:
$criteria = new CDbCriteria();
$criteria->condition = 'receiver_id = :receiverId';
$criteria->group = 'sender_id';
$criteria->order = 'priority_id DESC, added_on …Run Code Online (Sandbox Code Playgroud) 我有一个困难时期来配置我的.htaccess和urlManager在Yii的项目有在前端http://www.example.com和后端的http://www.example.com/backend与以下文件夹结构.欢迎任何帮助.谢谢.
/assets
/backend
/controllers
/config
main.php
/models
/views
/common
/models
/protected
/controllers
/config
main.php
/models
/views
.htaccess
backend.php
index.php
Run Code Online (Sandbox Code Playgroud)
解决方案:在@ bool.dev的帮助下,它的一切正常工作,所以我在这里添加了所有需要的最终文件.在前端我正在使用路径格式的url并隐藏index.php
/backend/config/main.php
$backend=dirname(dirname(__FILE__));
Yii::setPathOfAlias('backend', $backend);
return array(
'basePath' => $backend,
'controllerPath' => $backend.'/controllers',
'viewPath' => $backend.'/views',
'runtimePath' => $backend.'/runtime',
...);
Run Code Online (Sandbox Code Playgroud)
/protected/config/main.php
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
Run Code Online (Sandbox Code Playgroud)
的.htaccess
Options +FollowSymLinks
IndexIgnore */*
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /yii/example/
RewriteRule backend backend\.php [T=application/x-httpd-php]
# if a directory or a file exists, use it …Run Code Online (Sandbox Code Playgroud) 我试图从我的PHP脚本下载的文件就是这个:
http://www.navarra.es/appsext/DescargarFichero/default.aspx?codigoAcceso=OpenData&fichero=Farmacias/Farmacias.xml
Run Code Online (Sandbox Code Playgroud)
但我不能既不使用file_get_contents()也不使用cURL.我收到了错误Object reference not set to an instance of an object.
知道怎么做吗?
非常感谢,巴勃罗.
更新以添加代码:
$url = "http://www.navarra.es/appsext/DescargarFichero/default.aspx?codigoAcceso=OpenData&fichero=Farmacias/Farmacias.xml";
$simple = simplexml_load_file(file_get_contents($url));
foreach ($simple->farmacia as $farmacia)
{
var_dump($farmacia);
}
Run Code Online (Sandbox Code Playgroud)
而且该解决方案由于@Gordon:
$url = "http://www.navarra.es/appsext/DescargarFichero/default.aspx?codigoAcceso=OpenData&fichero=Farmacias/Farmacias.xml";
$file = file_get_contents($url, FALSE, stream_context_create(array('http' => array('user_agent' => 'php' ))));
$simple = simplexml_load_string($file);
Run Code Online (Sandbox Code Playgroud)