Propel - how can I set column name for PHP same as in DB automatically -


i used propel 2 , want have column-names php same in dhe db. used schema.xml this:

<?xml version="1.0" encoding="utf-8"?>  <database name="timetable" defaultidmethod="native">  	<table name="entry" phpname="entry">  		<column name="id" type="integer" required="true" primarykey="true" autoincrement="true" />  		<column name="date" type="date"  required="true" />  		<column name="timebegin" phpname="timebegin" type="time"  required="true" />  		<column name="timeend" type="time" required="true" />  		<column name="description" type="varchar" size="128" required="true" />  		<column name="expert_id" type="integer" required="true"/>  		<column name="project_id" type="integer" required="true"/>  		<foreign-key foreigntable="expert" phpname="expert" refphpname="entry">  			<reference local="expert_id" foreign="id"/>  		</foreign-key>  		<foreign-key foreigntable="project" phpname="project" refphpname="entry">  			<reference local="project_id" foreign="id"/>  		</foreign-key>  	</table>  </database>

propel generates names tables , columns. names in mysql-database written in correct manner, described in schema.xml. default propel generates names columns in php capital letter , behind lowercase. not want, got example "timeend" instead of "timeend" @ easy query:

<?php  	require 'vendor/autoload.php';  	include "generated-conf/config.php";  	  	$entry = entryquery::create()  	->find()  	->exportto('json');  	  	echo $entry;
produces:
{"entries":{"entry_0":{"id":1,"date":"11.09.2015","timebegin":"09:00","timeend":"19:00","description":"","expertid":5,"projectid":7}}} want this: id, date, timebegin, timeend, description, expertid, projectid (or expert_id, project_id).
know can force propel using every column phpname="timebegin" , on (like demonstraiting in example above), find inconvenient. should possible settings perhaps in propel.xml

you can use toarray method return column names.

$entry = entryquery::create()     ->find()     ->toarray(null, null, \propel\runtime\map\tablemap::type_fieldname); 

you can see snippet here:

http://sandbox.propelorm.org/46731f6

the resulting json's root bit different, i'm sure can work around that.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -