如何组织使用php动态创建的文件?(how to organize files created dynamically using php?)
我有一个PHP网站,它根据用户输入在服务器上创建和存储HTML模板文件。一个用户可以创建许多模板。因此,为了存储模板文件并将它们与DB记录相关联,我所做的是 -
“模板”是表格,其中包含有关模板的其他信息,例如谁创建了该模板等,并使用唯一的自动递增ID作为template_id
例如 - 如果模板ID是1001我将它转换为十六进制,即03e9现在我将十六进制数分成03和e9(在两个数字之后)成为文件夹,e9变成具有一些扩展名的文件为“e9.tpl”
如果我知道模板ID,我就可以从文件系统中找到模板。我不需要单独存储文件的路径。
这是一个好方法吗? 这种方法有什么不足? 还有其他方法比这更好吗?
将路径存储到数据库本身的优点/缺点是什么? 例如为了使用不同的光盘服务模板等?
I have an PHP website which creates and stores HTML template files on server based on user input.one user can create many templates.So to store the template files and associate them with the DB record ,what I do is-
"templates" is the table which hold other information about the template such as who created it etc. with unique auto-increment id as template_id
for example - if template id is 1001 I convert it to hex which is 03e9 Now I split the hex number into 03 & e9 (after two numbers) becomes folder and e9 becomes file with some extension as "e9.tpl"
This is how I can find out template from the file system if I know the template ID.I dont need to separately store the path to the file.
is it a good approach ? any shortfalls of this approach ? is there any other approach better than this ?
What are the advantages / disadvantages of storing the path to file in the database itself ? for example to enable using different discs serving templates etc.?
原文:https://stackoverflow.com/questions/2361723
最满意答案
您想要实现的目标称为“交错布局”。 它是由Pinterest在他们的iOS应用程序中引入的。
您将需要自定义集合视图布局, 本教程将解释如何。 或者,您可以使用现有解决方案之一,例如CHTCollectionViewWaterfallLayout 。
What you want to achieve is called "staggered layout". It was introduced by Pinterest in their iOS app.
You will need custom collection view layout, this tutorial will explain how. Alternatively, you can use one of the existing solutions, for example CHTCollectionViewWaterfallLayout.
相关问答
更多-
添加这两行 layout.minimumInteritemSpacing = 0 layout.minimumLineSpacing = 0 所以你有: // Do any additional setup after loading the view, typically from a nib. let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout() layout.sectionIn ...
-
在UICollectionViewFlowLayout中传播单元格的问题(Problems spreading out cells in UICollectionViewFlowLayout)[2023-05-17]
这里的问题是从中返回的项目 - (CGSize) collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath 与minimumInterimSpacing值重叠。 由于我正在寻找systemfontofsize = 8的东西,我需要确保我的临时间距超过该值。 将它设 ... -
单元格uicollectionviewflowlayout之间的边距相同(Same margin between cell uicollectionviewflowlayout)[2022-07-27]
您需要在sizeforitem中交叉检查您的代码 fileprivate let phoneSectionInsets = UIEdgeInsets(top: 14.0, left: 14.0, bottom: 20.0, right: 14.0) func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPa ... -
当您想要设置项目的大小时,不需要再次初始化UICollectionViewFlowLayout 。 您可以使用UICollectionViewDelegateFlowLayout以编程方式修改大小: public class MyCollectionDelegate : UICollectionViewDelegateFlowLayout { public override CGSize GetSizeForItem(UICollectionView collectionView, UICollec ...
-
您必须实现自定义UICollectionViewFlowLayout,并重写此方法: - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect 这里已经提出了类似的问题: 在UICollectionView中左对齐单元格 You have to implement custom UICollectionViewFlowLayout, and override this method: - (NSArray *)layoutAttributesF ...
-
正如评论中所提到的,必须在这里描述问题和一些后续思想的组合使我意识到尽管minimumInteritemSpacing是一个CGFloat,但是当你这样做时传递小数值及其行为是没有意义的。未定义。 这是因为,在像素比为1:1的设备上,没有半像素这样的东西。 事实恰巧在某些情况下,它表现得像我预期的那样,从而使我对真正的(而且相当明显的)问题视而不见。 希望阅读本文可以帮助其他人快速意识到错误。 As mentioned in the comments, a combination of having to ...
-
未定义UICollectionViewFlowLayout的行为(The behavior of the UICollectionViewFlowLayout is not defined)[2022-07-21]
原来这个UICollectionView是嵌套在UITableView 。 iOS 8引入了layoutMargins来代替内容偏移值。 根据这个问题: iOS 8 UITableView分隔符插入0不起作用 我不得不覆盖我的包含表格视图的单元格边距: -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { ... -
旋转时调整UICollectionViewFlowLayout单元格(Adjusting UICollectionViewFlowLayout cells on rotation)[2023-01-05]
旋转时需要刷新集合。 尝试下面的代码: - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { [yourCollectionview performBatchUpdates:nil completion:nil]; } You need to refresh collection while rotation . try following code : - (voi ... -
使UICollectionViewFlowLayout不使单元格居中于同一行(Make UICollectionViewFlowLayout not centering cells on the same line)[2022-02-13]
您想要实现的目标称为“交错布局”。 它是由Pinterest在他们的iOS应用程序中引入的。 您将需要自定义集合视图布局, 本教程将解释如何。 或者,您可以使用现有解决方案之一,例如CHTCollectionViewWaterfallLayout 。 What you want to achieve is called "staggered layout". It was introduced by Pinterest in their iOS app. You will need custom colle ... -
当你的细胞改变大小时,由他们决定如何处理(拉伸与重绘)。 这由UIView contentMode属性控制; 尝试将其设置为UIViewContentModeRedraw以使调整大小使setNeedsDisplay:等视图内容无效。 如果您直接将CALayers用作单元格的子图层,则可以将其needsDisplayOnBoundsChange设置为YES以获得相同的效果。 When your cells change size, it's up to them how to handle that (str ...