Custom query in model

In my model I have a "afterCreate()". Within "afterCreate()" I would like to execute a simple custom query that will insert a record into another table with the foreign key of the record just created.

If you could provide an example of how to do this with a custom query (ie no association to model) and also using Phalcon to save (ie there is an association).

Thank you in advance for the help.


Hey man

You can use modelManager in Phalcon

     $phql = "UPDATE Phalcontip\ModelsJob SET Phalcontip\Models\Job.status = ?0 WHERE Phalcontip\Models\ = ?1";
            $result = $this->modelsManager->executeQuery($phql, array(
                0 => Job::STATUS_DISPLAY,
                1 => $idJob


I wound up running this and it worked.

public function afterCreate()
    $data = new Motors();
        "car_id" => $this->id,
        "identifier" => 1



Thiện I will look into your response. Thank You!