我正在使用Propel 2.我通过关系保湿对象,如下:
$return = OrderQuery::create()
->joinWith('Customer')
->joinWith('Status')
->find()
->toArray(TableMap::TYPE_PHPNAME, true, [], true);
Run Code Online (Sandbox Code Playgroud)
生成的数组看起来像这样:
{
"Id": 1,
"CustomerId": 1,
"StatusId": 1,
"Initiated": "2016-01-01T01:01:01+00:00",
"Customer": {
"Id": 1,
"Forname": "Test",
"Surname": "Smith",
"Orders": [
"*RECURSION*"
]
}
"Status": {
"Id": 1,
"Title": "title 1",
"Priority": 1,
"Orders": [
"*RECURSION*"
]
},
}
Run Code Online (Sandbox Code Playgroud)
我想删除值为的字段*RECURSION*.我尝试使用$alreadyDumpedObjects(第3个)参数,toArray()但似乎没有帮助.我也可以通过unset()调用来做某种形式的数组行走,但是我希望有更好的方法,也许是格式化程序或其他东西?
对于奖励积分,我非常想删除定义外键关系的列.例如,CustomerId会去,但Customer会留下来.
有没有办法让 Propel 在添加/更新行时自动转义作为保留字的列名?
现在我有一个名为“order”的列,当我尝试使用更新时
$row->setOrder(1)->save();
Run Code Online (Sandbox Code Playgroud)
我收到语法错误“PHP 致命错误:未捕获的异常 'PDOException',消息为 'SQLSTATE[42601]:语法错误:7 错误:“订单”处或附近的语法错误\nLINE 1:更新条款 SET order=$1 WHERE 条款。 id=$2\n ^'"
我正在使用带PostgreSQL的Propel2 ORM,这是我的配置:
propel:
database:
connections:
default:
adapter: pgsql
dsn: pgsql:host=localhost;port=5432;dbname=sps_db
user: postgres
password: postgres
settings:
charset: utf8
Run Code Online (Sandbox Code Playgroud)
这是我的示例架构:
<?xml version="1.0" encoding="utf-8"?>
<database name="default" defaultIdMethod="native" defaultPhpNamingMethod="underscore" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://xsd.propelorm.org/1.6/database.xsd" >
<table name="product" description="Available products table">
<column name="id_product" autoIncrement="true" primaryKey="true" type="BIGINT" required="true"/>
<column name="id_product_barcode" type="BIGINT" />
<column name="name" type="VARCHAR" size="200" required="true" />
<column name="id_product_manufacturer" type="INTEGER" required="true" />
<column name="id_product_category" type="INTEGER" required="true"/>
<column name="id_product_photo" type="BIGINT" />
</table>
</database>
Run Code Online (Sandbox Code Playgroud)
PostgreSQL 9.5已经在Ubuntu 16.04上全新安装.当我运行propel diff并且propel migrate第一次一切正常并且生成表格时.
这是第一个生成的迁移:http://pastebin.com/hK9qwfeA
如果在不更改架构的情况下,我重新运行diff propel检测更改(这些更改不存在):
Comparing …Run Code Online (Sandbox Code Playgroud)