Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How would this select in Phalcon ?. How a function or using model or something else?

Hi, I use this code to generate my next PRIMARY code with PURE PHP , as might write in Phalcon, If possible with model

$prefijo ="CLI, TRA, PRO" ONLY 3 letter or IF you analyze the code can change to more
$table = Table to where it will generate the code
$campoPrimario = Field this table as the primary key or you want to generate you the code

$prefijo="CLI"

select ('$prefijo' || (case when max($campoPrimario)  IS NULL THEN '0000000001' ELSE LPAD((SUBSTRING(max($campoPrimario), 4) + 1), 10, '0') END)) AS codigo
from $tabla

RESULT="CLI0000000001"

CONSULTATION IS MADE FOR ORACLE DATABASE COMMAND LPDAD ADVANTAGE TO DIVIDE THE CHAIN AS A LEFT OR RIGHT IN EXCEL

I prefer to use modelsManager. You can do case in it.



34.2k

And as would using ModelManager