Code Kings
Published in

Code Kings

Phalcon 4 | PHP 7 → Getting another Segmentation Fault error when trying to send conditions to related model in ORM.

Photo by Joshua Hoehne on Unsplash

THE ISSUE

I came across another Segmentation Fault error when trying to run this code:

$example = ExampleModel::findFirst(CONDITIONS_EXAMPLE_HERE)$related_model = $example->getExampleModelName([
'conditions'=>'zip_code=?1',
'bind'=>[1=>90210]
]);

THE SOLUTION

In Phalcon 4, it seems that you are unable to use indexed bind parameters and instead have to use named parameters. The following code should work for you:

$example = ExampleModel::findFirst(CONDITIONS_EXAMPLE_HERE)$related_model = $example->getExampleModelName([
'conditions'=>'zip_code=:namedBindParameterHere:',
'bind'=>['namedBindParameterHere'=>90210]
]);

Happy Coding!

--

--

--

Programming tips & tricks from professionals

Recommended from Medium

SSH to Red Hat with Docker

One Rest API for your Lifetime Salesforce Implementation with Flow Builder as Controller

Creating a repository using git and GitHub

How to use composite indexes to speed up time-series queries

Mobile App Development Process: A Step-by-Step Guide [2021]

Flask Datta PRO — Update (Improved Auth, User Roles)

Flask Datta Able PRO — Mobile View

Amazon EKS upgrade journey from 1.15 to 1.16

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Tony Mucci

Tony Mucci

Founder of My Company Tools • Co-Founder/Former CTO of Dree • Co-Founder of Eklect Enterprises. Opinions on this blog are my own.

More from Medium

Web Stack Weekly — Issue #4

Configuring Laravel 7 For Use With PhpRedis using Homestead

Laravel — HTTP Testing without Database

Laravel 8: how to customize the redirect according to the role of the registering user with Fortify