本文整理汇总了PHP中Transaction::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Transaction::toArray方法的具体用法?PHP Transaction::toArray怎么用?PHP Transaction::toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transaction
的用法示例。
在下文中一共展示了Transaction::toArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fromTransaction
public static function fromTransaction(Transaction $transaction, PropelPDO $con = null)
{
$transactionId = $transaction->getId();
$bookingData = array();
$bookings = BookingQuery::create()->filterByTransactionId($transactionId)->find($con);
foreach ($bookings as $booking) {
$bookingData[] = self::from($booking, $con);
}
$clockingData = array();
$clockings = ClockingQuery::create()->joinTransactionClocking()->joinWith('ClockingType')->add(TransactionClockingPeer::TRANSACTION_ID, $transactionId)->find($con);
foreach ($clockings as $clocking) {
$clockingData[] = self::from($clocking, $con) + array('Type' => self::from($clocking->getClockingType($con), $con));
}
return array('Start' => $transaction->getStart('U'), 'End' => $transaction->getEnd('U'), 'Bookings' => $bookingData, 'Clockings' => $clockingData, 'User' => self::from($transaction->getUserRelatedByUserId($con), $con)) + $transaction->toArray();
}
示例2: toArray
/**
* Exports the object as an array.
*
* You can specify the key type of the array by passing one of the class
* type constants.
*
* @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
* Defaults to BasePeer::TYPE_PHPNAME.
* @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
* @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
* @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
*
* @return array an associative array containing the field names (as keys) and field values
*/
public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
{
if (isset($alreadyDumpedObjects['TransactionClocking'][serialize($this->getPrimaryKey())])) {
return '*RECURSION*';
}
$alreadyDumpedObjects['TransactionClocking'][serialize($this->getPrimaryKey())] = true;
$keys = TransactionClockingPeer::getFieldNames($keyType);
$result = array($keys[0] => $this->getTransactionId(), $keys[1] => $this->getClockingId());
if ($includeForeignObjects) {
if (null !== $this->aClocking) {
$result['Clocking'] = $this->aClocking->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->aTransaction) {
$result['Transaction'] = $this->aTransaction->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
return $result;
}
示例3: toArray
/**
* Exports the object as an array.
*
* You can specify the key type of the array by passing one of the class
* type constants.
*
* @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
* Defaults to BasePeer::TYPE_PHPNAME.
* @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
* @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
* @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
*
* @return array an associative array containing the field names (as keys) and field values
*/
public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
{
if (isset($alreadyDumpedObjects['Booking'][$this->getPrimaryKey()])) {
return '*RECURSION*';
}
$alreadyDumpedObjects['Booking'][$this->getPrimaryKey()] = true;
$keys = BookingPeer::getFieldNames($keyType);
$result = array($keys[0] => $this->getId(), $keys[1] => $this->getTransactionId(), $keys[2] => $this->getBookingTypeId(), $keys[3] => $this->getLabel(), $keys[4] => $this->getValue());
if ($includeForeignObjects) {
if (null !== $this->aTransaction) {
$result['Transaction'] = $this->aTransaction->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->aBookingType) {
$result['BookingType'] = $this->aBookingType->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
return $result;
}
示例4: newTransaction
public function newTransaction()
{
$transaction = new Transaction();
$transaction->amount = floatval(Input::get('amount'));
$transaction->fireflyuser_id = Auth::user()->id;
$transaction->date = Input::get('date');
$transaction->onetime = Input::get('onetime') == 'on' ? 1 : 0;
$transaction->description = Input::get('description');
if (Input::get('type') == 'min') {
$transaction->amount = $transaction->amount * -1;
}
if (!is_null(Input::get('account'))) {
$account = Auth::user()->accounts()->find(Input::get('account'));
if (!is_null($account)) {
$transaction->account_id = $account->id;
}
}
// budget
if (intval(Input::get('budget')) > 0) {
$budget = Auth::user()->budgets()->find(intval(Input::get('budget')));
if (!is_null($budget)) {
$transaction->budget_id = $budget->id;
}
}
// category
if (strlen(Input::get('category')) != 0) {
$categories = Auth::user()->categories()->get();
//->where('name','=',Input::get('category'))->first();
$category = null;
foreach ($categories as $cat) {
if (Crypt::decrypt($cat->name) == Input::get('category')) {
$category = $cat;
break;
}
}
unset($cat, $categories);
if (is_null($category)) {
$category = new Category();
$category->fireflyuser_id = Auth::user()->id;
$category->name = Input::get('category');
$category->showtrend = 0;
$category->icon_id = Icon::first()->id;
// FIXME moet niet hardcoded
$validator = Validator::make($category->toArray(), Category::$rules);
if ($validator->passes()) {
$category->name = Crypt::encrypt($category->name);
$category->save();
$transaction->category_id = $category->id;
}
} else {
$transaction->category_id = $category->id;
}
}
// beneficiary
if (strlen(Input::get('beneficiary')) != 0) {
$beneficiaries = Auth::user()->beneficiaries()->get();
//->where('name','=',Input::get('beneficiary'))->first();
$beneficiary = null;
foreach ($beneficiaries as $ben) {
if (Crypt::decrypt($ben->name) == Input::get('beneficiary')) {
$beneficiary = $ben;
break;
}
}
unset($ben, $categories);
if (is_null($beneficiary)) {
$beneficiary = new Beneficiary();
$beneficiary->fireflyuser_id = Auth::user()->id;
$beneficiary->name = Input::get('beneficiary');
$validator = Validator::make($beneficiary->toArray(), Beneficiary::$rules);
if ($validator->passes()) {
$beneficiary->name = Crypt::encrypt($beneficiary->name);
$beneficiary->save();
$transaction->beneficiary_id = $beneficiary->id;
}
} else {
$transaction->beneficiary_id = $beneficiary->id;
}
}
$validator = Validator::make($transaction->toArray(), Transaction::$rules);
$transaction->description = Crypt::encrypt($transaction->description);
if ($validator->fails()) {
return Redirect::to('/home/transaction/add')->withErrors($validator)->withInput();
} else {
// the transaction was valid! lets save some tags!
$transaction->save();
if (Input::get('tags') != null && strlen(Input::get('tags')) > 0) {
$tags = explode(',', Input::get('tags'));
foreach ($tags as $tag) {
$dbTag = Tag::findOrCreate($tag);
$transaction->tags()->attach($dbTag);
}
}
return Redirect::to('/home/transaction/add');
}
}