I'm having an issue with models.
when running find or query on a model the afterfetch is not called, nor returned in the object. Neither is the toarray from the model.
If i change to findfirst then both AfterFetch and toarray are both present.
class DataExports extends extends \Phalcon\Mvc\Model
{
public function initialize()
{
$this->setConnectionService('dbPostgres');
}
public function initialize() {
parent::initialize();
$this->setSchema('public');
$this->setSource('tbl_data_exports');
}
public function afterFetch() {
var_dump('afterFetch');
$this->file_data = base64_encode(stream_get_contents($this->file_data));
//$this->AfterFetchSingle($this);
}
}
public function select() {
$dataExports = DataExports::find();
$dataExports2 = DataExports::findFirst(6683);
print_r(get_class_methods($dataExports));
print_r(get_class_methods($dataExports2));
return $dataExports->toArray();
}
find return
Array
(
[0] => __construct
[1] => valid
[2] => toArray
[3] => serialize
[4] => unserialize
[5] => next
[6] => key
[7] => rewind
[8] => seek
[9] => count
[10] => offsetExists
[11] => offsetGet
[12] => offsetSet
[13] => offsetUnset
[14] => getType
[15] => getFirst
[16] => getLast
[17] => setIsFresh
[18] => isFresh
[19] => setHydrateMode
[20] => getHydrateMode
[21] => getCache
[22] => current
[23] => getMessages
[24] => delete
[25] => filter
)
Find First return (processQuery and AfterFetchSingle are 2 methods i created for testing)
Array
(
[0] => initialize
[1] => afterFetch
[2] => processQuery
[3] => AfterFetchSingle
[4] => toArray
[5] => __construct
[6] => setDI
[7] => getDI
[8] => getModelsMetaData
[9] => getModelsManager
[10] => setTransaction
[11] => getSource
[12] => getSchema
[13] => setConnectionService
[14] => setReadConnectionService
[15] => setWriteConnectionService
[16] => getReadConnectionService
[17] => getWriteConnectionService
[18] => setDirtyState
[19] => getDirtyState
[20] => getReadConnection
[21] => getWriteConnection
[22] => assign
[23] => cloneResultMap
[24] => cloneResultMapHydrate
[25] => cloneResult
[26] => find
[27] => findFirst
[28] => query
[29] => count
[30] => sum
[31] => maximum
[32] => minimum
[33] => average
[34] => fireEvent
[35] => fireEventCancel
[36] => appendMessage
[37] => validationHasFailed
[38] => getMessages
[39] => save
[40] => create
[41] => update
[42] => delete
[43] => getOperationMade
[44] => refresh
[45] => skipOperation
[46] => readAttribute
[47] => writeAttribute
[48] => hasOne
[49] => belongsTo
[50] => hasMany
[51] => hasManyToMany
[52] => addBehavior
[53] => setSnapshotData
[54] => hasSnapshotData
[55] => getSnapshotData
[56] => hasChanged
[57] => getChangedFields
[58] => getRelated
[59] => __call
[60] => __callStatic
[61] => __set
[62] => __get
[63] => __isset
[64] => serialize
[65] => unserialize
[66] => dump
[67] => setup
)