标签: propel2

在Propel中使用toArray()时,是否可以删除带*RECURSION*的字段?

我正在使用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会留下来.

php propel propel2

7
推荐指数
1
解决办法
468
查看次数

当 MySQL 服务器消失时 Propel2 重新连接

我有一项长期运行的工作,使用Propel2. 然而,有时它会因臭名昭著的mysql server has gone away错误而崩溃。我想通过重新连接到服务器来恢复此错误,也许等待几秒钟后。有谁知道如何在连接丢失后强制 Propel 重新连接?我没有找到任何如何从PropelPDO API 中执行此操作的线索。

php mysql pdo propel2

5
推荐指数
1
解决办法
771
查看次数

在表名或列名中使用保留关键字时收到 Propel 语法错误

有没有办法让 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 ^'"

mysql postgresql propel syntax-error propel2

4
推荐指数
1
解决办法
351
查看次数

Propel2 diff使用PostgreSQL检测不存在的更改

我正在使用带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)

php postgresql orm propel propel2

2
推荐指数
1
解决办法
180
查看次数

标签 统计

propel2 ×4

php ×3

propel ×3

mysql ×2

postgresql ×2

orm ×1

pdo ×1

syntax-error ×1