我觉得我必须错过一些非常简单的事情.这是一个非常简单的任务,我想要做的就是:
SELECT * FROM lookup_items
JOIN lookup ON lookup_items.lookup_id = lookup.id
Run Code Online (Sandbox Code Playgroud)
这将返回常规SQL中所有连接表的所有列.这是我在zf2中的尝试:
$select = new Select();
$select->from('lookup_items');
$select->join('lookup', 'lookup_items.lookup_id = lookup.id');
Run Code Online (Sandbox Code Playgroud)
结果集仅包含'lookup_items'中的列.我已经尝试了各种方法来获取"查找"列,包括:
$select->columns(array('lookup_items.*', 'lookup.*'));
Run Code Online (Sandbox Code Playgroud)
但他们都爆炸了.当然有一种方法可以做到这一点,它就是这么简单,我完全错过了它.
我认为一个简单的例子可以避免混淆,但这里有更多的代码:
class LookupItemsTable extends AbstractTableGateway
{
public function getList($resource)
{
$system_name = str_replace('*', '%', strtoupper($resource));
$joinTable = 'lookup';
$select = new Select();
$select->from($this->table);
$select->join($joinTable, "{$this->table}.lookup_id = {$joinTable}.id");
$where = array();
$where[] = "{$this->table}.enabled is true";
$where[] = "{$joinTable}.enabled is true";
$where[] = "UPPER({$joinTable}.system_name) ilike '{$system_name}'";
$select->where($where);
$sort[] = 'sort_order ASC';
$sort[] = 'value ASC';
$select->order($sort); …Run Code Online (Sandbox Code Playgroud) 我从zf2 api调用中得到了一个奇怪的编码问题.我已经验证了api在内部工作,并且它应该发送回来的响应来自api例程,该例程采用图像文件并裁剪它:
$result = new ViewModel(array('output'=>$output, 'response'=>json_encode($response)));
Run Code Online (Sandbox Code Playgroud)
在结果发送之前转储$ result,如下所示:
[output] => json
[response] =>{"data":"http:\/\/dev.xxxxx.com\/tools\/files\/temporary_files\/f16da1965e4d0c487ae7692f4b51558b917c238e.1","status":"OK"}
Run Code Online (Sandbox Code Playgroud)
但我回来的实际反应是这样的:
^_<8b>^H^@^@^@^@^@^@^C%ÍM
^B!^T^@໸^Nß¹Â,:B<õI<82><8e><83>¾<82><88>î^Ðò[}o<96><80><80>ìNt¬B4(5^R>y*<93>F ¥ï<ö&¨÷:E.^U§ lG^_0^·¿³4 ¤7^ZU:Gå, 5~É*h©µ^K^Ú¸\^\rÉNl^RÐcþÖëÆ>_Id»'<83>^@^@^@
Run Code Online (Sandbox Code Playgroud)
以下是我使用curl调用api的方法:
$client = new Client($api_url);
$adapter = new Curl();
$adapter->setCurlOption(CURLOPT_SSL_VERIFYPEER, false);
$client->setAdapter($adapter);
$request = new Request();
$request->setUri($api_url);
$request->setMethod(\Zend\Http\Request::METHOD_POST);
$request->setContent($postString);
$response = $client->dispatch($request);
$responseContent = $response->getContent();
Run Code Online (Sandbox Code Playgroud)
看起来编码的部分是$ responseContent的转储.认为它可能是gzip,因为响应标题说内容类型是gzip,我已经尝试了各种解压缩调用,但无济于事.到底发生了什么事?
我们刚刚开始使用zf2,所以其他人制作了一个Thumbnail服务器模块,然后我添加了一个Lookup服务器模块.我称之为服务器,因为它们都是RESTful apis.最初它们似乎在一起工作,但有人对我的模块进行了一些更改,现在除非从application.config.php模块列表中删除Lookup,否则缩略图服务器将无法工作.Lookup服务器无论如何都可以.查看代码,我看不到对Lookup所做的更改会如何影响Thumbnail.我得到的错误看起来像这样:
<h1>A 404 error occurred</h1>
<h2>Page not found.</h2>
<p>The requested controller was unable to dispatch the request.</p>
<dl>
<dt>Controller:</dt>
<dd>Lookup\Controller\Lookup</dd>
</dl>
Run Code Online (Sandbox Code Playgroud)
这是application.config.php看起来像:
<?php
return array(
'modules' => array(
'Application',
'SanRestful',
'Album',
'AlbumRest',
'Thumbnail',
'Lookup',
'AP_XmlStrategy',
),
'module_listener_options' => array(
'config_glob_paths' => array(
'config/autoload/{,*.}{global,local}.php',
'config/autoload/{,*.}' . (getenv('APPLICATION_ENV') ?: 'production') . '.php',
),
'module_paths' => array(
'./module',
'./vendor',
),
),
);
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,最初的专辑模块和其他一些实验模块.My Lookup模块使用Allessandro Pietrobelli提供的优秀AP_XmlStrategy模块.
下面是缩略图module.config.php.它有一个可能没有被使用的约束,因为没有名为"id"的参数,但这不应该搞乱,是吗?
<?php
return array(
'controllers' => array( …Run Code Online (Sandbox Code Playgroud) 我使用了一个类 MapMultiController,它扩展了 UIViewController,并从我的 ListViewController 内部实例化,它也扩展了 UIViewController,如下所示:
@interface MapMultiController : UIViewController <UINavigationControllerDelegate, UINavigationBarDelegate> {
MKMapView *mapView;
UISegmentedControl *barStyleSegControl;
bool wasUpdated;
}
Run Code Online (Sandbox Code Playgroud)
然后这个:
MapMultiController *controller = [[MapMultiController alloc] initWithNibName:@"MapMultiController" bundle:nil];
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
[controller release];
Run Code Online (Sandbox Code Playgroud)
这一切以前都有效,但后来我从 ListViewController 中注释掉了分配和所有这些,并做了一些其他的事情,现在当我试图把它放回去时,它说“意外的接口名称‘MapMultiController’”,并且当然之后的一切都不起作用。
但在我看来一切都是正确的!怎么了?
是否可以autoincrement像在Postgres中那样在SQL Server中设置字段的下一个值?
对于好奇,这是整个背景故事.我的公司过去常常使用Postgres,它允许您轻松地将自动增量字段的下一个值设置为任意值.
新公司买了旧公司,现在我们将Postgres数据导入SQL Server.不知何故AcctID,账户上的自动增量字段设置为9位数字,即使有数千个8位数字.显然有人在Postgres做了一段时间,因为一些现在不为人知的原因.
所以现在在新的SQL Server数据库中,新帐户有9位帐户ID,但客户的会计软件无法处理9位帐号,因此他们添加的任何新帐户都无法由其会计部门处理直到这个问题得到解决
当然,最多有72个不同的表可以依赖于AcctID字段Accounts,并且客户端在实现所涉及的问题之前创建了大约360个新帐户,因此保存该数据,截断表并重新插入数据将是繁重的任务.
更好的是将自动增量值设置AcctID为最后的8位数值+ 1.然后,至少他们能够在处理9位数帐户的解决方案时添加新帐户.事实上,他们声称他们只需要他们添加的360个帐户中的3个.
那么可以像在Postgres中那样重置SQL Server中字段的自动增量值吗?
我正在回调zf2 api调用中似乎是gzip压缩的数据.内容类型是gzip,内容主体看起来是编码的.所以我尝试了这个:
$decoded = $response->decodeGzip($response->getContent());
Run Code Online (Sandbox Code Playgroud)
我收回了这个错误:
Call to protected method Zend\Http\Response::decodeGzip()
Run Code Online (Sandbox Code Playgroud)
为什么受到保护?似乎解码gzip压缩数据是一件很方便的事情.