假设我有一个实体,它引用自己来映射父子关系
class Food
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\ManyToOne(targetEntity="Food", inversedBy="foodChildren")
* @ORM\JoinColumn(name="food_group_id", nullable=true)
*/
protected $foodGroup;
/**
* @ORM\OneToMany(targetEntity="Food", mappedBy="foodGroup", fetch="LAZY", cascade={"remove"})
*/
protected $foodChildren;
Run Code Online (Sandbox Code Playgroud)
我有一个用例,我希望得到food_group_id一个实体而不从数据库中获取完整的父对象.使用fetch="LAZY"不会让Doctrine再次查询.在获得时有没有办法只返回ID $food->getFoodGroup()?
我有一种情况,其中两个web服务器设置为nginx作为loadbalancer并且是后端自己.分布是Debian Wheezy.两台服务器上的配置相同(四核,32GB RAM)
TCP
#/etc/sysctl.conf
vm.swappiness=0
net.ipv4.tcp_window_scaling=1
net.ipv4.tcp_timestamps=1
net.ipv4.tcp_sack=1
net.ipv4.ip_local_port_range=2000 65535
net.ipv4.tcp_max_syn_backlog=65535
net.core.somaxconn=65535
net.ipv4.tcp_max_tw_buckets=2000000
net.core.netdev_max_backlog=65535
net.ipv4.tcp_rfc1337=1
net.ipv4.tcp_fin_timeout=5
net.ipv4.tcp_keepalive_intvl=15
net.ipv4.tcp_keepalive_probes=5
net.core.rmem_default=8388608
net.core.rmem_max=16777216
net.core.wmem_max=16777216
net.ipv4.tcp_rmem=4096 87380 16777216
net.ipv4.tcp_wmem=4096 16384 16777216
net.ipv4.tcp_congestion_control=cubic
net.ipv4.tcp_tw_reuse=1
fs.file-max=3000000
Run Code Online (Sandbox Code Playgroud)
Nginx的
#/etc/nginx/nginx.conf
user www-data www-data;
worker_processes 8;
worker_rlimit_nofile 300000;
pid /run/nginx.pid;
events {
worker_connections 8192;
use epoll;
#multi_accept on;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 10;
types_hash_max_size 2048;
server_tokens off;
open_file_cache max=200000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 5;
open_file_cache_errors on;
gzip on;
gzip_vary on;
gzip_proxied any; …Run Code Online (Sandbox Code Playgroud) $image = "[...]"; //binary string containing PNG image
$file = fopen('image.tmp', 'wb');
fputs($file, $image);
fclose($file);
$image = new Imagick('PNG:image.tmp');
$image->thumbnailImage($width, $height);
$image->setImageFormat('jpg');
$image->setCompressionQuality(97);
$image->writeImage('image.jpg');
Run Code Online (Sandbox Code Playgroud)
以上不起作用,并为我提供了这张图片的黑色图像.做的时候
[...]
$image->setImageFormat('png');
$image->setCompressionQuality(97);
$image->writeImage('image.png');
Run Code Online (Sandbox Code Playgroud)
一切都很好.我认为它必须用透明背景做一些事情,而JPG格式却没有.任何人都可以帮助解决这个问题(想象力没有记录得很好,所以我不知道如何帮助自己).
MSSQL 2005数据库具有排序规则"German_Phonebook_BIN"(但这并不重要).通过PDO和FreeTDS(在Debian Squeeze下使用PHP)完成与db的连接.当我尝试从表中选择日期时间值时,我得到如下结果:
2008年4月1日12:00:00:000
但我希望得到
2008-01-01 00:00:00
(注意,时间00:00:00转换为12:00:00,不知道为什么00:00 = 12:00 ???)我没办法操纵这些SELECT陈述(做一个转换用CONVERT).我在PDO中找不到设置日期格式的选项.SET DATEFORMAT并且SET LANGUAGE在查询运行之前也不会影响这一点.任何人都可以提示在PDO中可以完成(并且只能完成)吗?(顺便说一下,PEAR :: MBD2以预期的格式返回datetime列,但是当它必须与UTF-8和MSSQL一起工作时,MDB2很可怕)
好的,一些更多信息(仅显示重要的片段):
<?php
$this->_dsn = 'dblib:host=' . $this->_db['host'] . ';dbname=' . $this->_db['database'] . ';charset=UTF-8';
$this->_handle = new PDO($this->_dsn, $this->_db['user'], $this->_db['password']);
print_r($this->_handle->query("SELECT [date_column] FROM [some_table]"));
Run Code Online (Sandbox Code Playgroud) 目前,我不明白为什么在处理UTF-8时在PHP中使用mbstring函数非常重要?我在linux下的语言环境已经设置为UTF-8,那么为什么函数不能strlen,preg_replace等等默认情况下无法正常工作?
我正在使用Symfony2.2和StofDoctrineExtensionsBundle(以及Gedmo DoctrineExtensions).我有一个简单的实体
/**
* @ORM\Entity
* @Gedmo\Loggable
* @ORM\Table(name="person")
*/
class Person {
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
[...]
/**
* @ORM\Column(type="datetime", nullable=true)
* @Assert\NotBlank()
* @Assert\Date()
* @Gedmo\Versioned
*/
protected $birthdate;
}
Run Code Online (Sandbox Code Playgroud)
更改现有对象的属性时,将在表中完成日志条目ext_log_entries.此日志表中的条目仅包含已更改的列.我可以通过以下方式阅读日志:
$em = $this->getManager();
$repo = $em->getRepository('Gedmo\Loggable\Entity\LogEntry');
$person_repo = $em->getRepository('Acme\MainBundle\Entity\Person');
$person = $person_repo->find(1);
$log = $repo->findBy(array('objectId' => $person->getId()));
foreach ($log as $log_entry) { var_dump($log_entry->getData()); }
Run Code Online (Sandbox Code Playgroud)
但我不明白的是,为什么字段birthdate总是包含在日志条目中,即使它没有改变.这里有一些三个日志条目的例子:
array(9) {
["salutation"]=>
string(4) "Herr"
["firstname"]=>
string(3) "Max"
["lastname"]=>
string(6) "Muster"
["street"]=> …Run Code Online (Sandbox Code Playgroud) symfony doctrine-orm doctrine-extensions symfony-2.2 stofdoctrineextensions
我正在解析很多网站.一切正常,我正在读取转换编码的字符集声明.现在我遇到了http://celleheute.de/sonntagsfuhrung-3/的问题.
HTML元标记说,内容编码为ISO-8859-2,但HTTP标头说,它是UTF-8.实际上,内容是UTF编码的,所以当我的解析器尝试将内容转换为ISO时,它会破坏一些字符.
现在我的问题是,我更喜欢哪种声明?我可以忽略元标记,当我可以在HTTP标头中找到声明,反之亦然?大多数网络浏览器会做什么?
我已经尝试了将近一周的时间来分发交易.我在MSSQL上有一些尝试从MySQL中选择数据的程序.我需要在一个(!)事务中执行此操作.当时我已经建立了与OpenLink的单层MySQL驱动程序,其中规定我,XA交易成功运行(有配置ODBC连接后集成测试按钮)在MSSQL ODBC连接.然后我通过MSDASQL在MSSQL中建立了一个链接服务器到这个ODBC连接,但是在做的时候
begin distributed transaction
select * from optin..lu_source_proc
select * from openquery(optinxa, 'SELECT * FROM tbl_source_proc')
commit transaction
Run Code Online (Sandbox Code Playgroud)
我收到错误,在实际交易中没有进一步的交易.(Der OLE DB-Anbieter "MSDASQL" für den Verbindungsserver "optinxa" hat die Meldung "Es können keine weiteren Transaktionen in dieser Sitzung gestartet werden." zurückgeben.)
另一个测试:
set transaction isolation level serializable
begin transaction
select * from optin..lu_source_proc
select * from openquery(optinxa, 'SELECT * FROM tbl_source_proc')
commit transaction
Run Code Online (Sandbox Code Playgroud)
结果Der OLE DB-Anbieter "MSDASQL" für den Verbindungsserver "optinxa" hat die Meldung "[OpenLink][ODBC][Driver]Driver does not …
mysql sql-server odbc sql-server-2005 distributed-transactions
我们想要创建一个相对简单的文档存储,但有一些要求.我的想法是,文件在立即到达存储时由单独的工具/守护进程扫描和处理.
(伪)DMS应该通过NFS和Samba提供访问.正如我到目前为止看到的那样,管道可以将传入的文件传递给某些钩子.但我想知道是否有办法将目录创建为管道.我见过只有命名管道了.
应该在此目录中获取任何传入文件的进程是一个PHP脚本,它应该执行类似MIME类型猜测,CRC32检查(对数据库中的值)...有人提示如何执行此操作吗?
编辑:我希望通过以下解释更清楚一点 - 我正在寻找一种通过Samba和NFS提供"端点"的方法,其中可以放置由病毒扫描和元处理立即处理的文件(并最终存储) .
我正在寻找一种方法为一个线程明确选择一个表行.我编写了一个爬虫程序,它可以处理大约50个并行进程.每个进程都必须从表中取出一行并进行处理.
CREATE TABLE `crawler_queue` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`url` text NOT NULL,
`class_id` tinyint(3) unsigned NOT NULL,
`server_id` tinyint(3) unsigned NOT NULL,
`proc_id` mediumint(8) unsigned NOT NULL,
`prio` tinyint(3) unsigned NOT NULL,
`inserted` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
KEY `proc_id` (`proc_id`),
KEY `app_id` (`app_id`),
KEY `crawler` (`class_id`,`prio`,`proc_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8
Run Code Online (Sandbox Code Playgroud)
现在我的流程执行以下操作:
SELECT * FROM crawler_queue WHERE class_id=2 AND prio=20 AND proc_id=0 ORDER BY id LIMIT 1 FOR UPDATEUPDATE crawler_queue …