We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

I can not edit or delete when using Oracle database.

I can not edit or delete when using the Oracle database as the FindFirstby command does not return any data even when the data is've created the same database in Oracle and MySQL but only Oracle does not work, and I have not been able to hayar solution in long, basic things like that exist if the fields are case-sensitive and revise, UTF8 encoding. It is not that otherwise could select data in a table, because I ran out of ideas.

This is my view

<?php use Phalcon\Tag; ?>

<?php echo $this->getContent(); ?>

<table width="100%">
    <tr>
        <td align="left">
            <?php echo $this->tag->linkTo(array("spm_contacto/index", "Go Back")); ?>
        </td>
        <td align="right">
            <?php echo $this->tag->linkTo(array("spm_contacto/new", "Create ")); ?>
        </td>
    </tr>
</table>

<table class="browse" align="center">
    <thead>
        <tr>
            <th>CODIGO</th>
            <th>CEDULA</th>
            <th>RUC/IDE</th>
            <th>NOMBRE</th>
            <th>ESTADO</th>
            <th>TELEFONO</th>
            <th>DIRECCION</th>
            <th>AREA</th>
            <th>CARGO</th>
            <th>TIPOXX</th>
            <th>ELIMINAR</th>
            <th>EDITAR</th>
         </tr>
    </thead>
    <tbody>
    <?php foreach ($page->items as $SPM_CONTACTO) { ?>
        <tr>
            <td><?php echo $SPM_CONTACTO->CONT_CODIGO ?></td>
            <td><?php echo $SPM_CONTACTO->CONT_CEDULA ?></td>
            <td><?php echo $SPM_CONTACTO->CONT_RUCIDE ?></td>
            <td><?php echo $SPM_CONTACTO->CONT_NOMBRE ?></td>
            <td><?php echo $SPM_CONTACTO->CON_ESTADO ?></td>
            <td><?php echo $SPM_CONTACTO->CONT_TELEFO ?></td>
            <td><?php echo $SPM_CONTACTO->CONT_DIRECC ?></td>
            <td><?php echo $SPM_CONTACTO->CONT_AREA ?></td>
            <td><?php echo $SPM_CONTACTO->CONT_CARGO ?></td>
            <td><?php echo $SPM_CONTACTO->CONT_TIPOXX ?></td>
            <td><?php echo $this->tag->linkTo(array("spm_contacto/edit/" . $SPM_CONTACTO->CONT_CODIGO, "Editar")); ?></td>
            <td><?php echo $this->tag->linkTo(array("spm_contacto/delete/" . $SPM_CONTACTO->CONT_CODIGO, "Eliminar")); ?></td>
        </tr>
    <?php } ?>
    </tbody>
    <tbody>
        <tr>
            <td colspan="2" align="right">
                <table align="center">
                    <tr>
                        <td><?php echo $this->tag->linkTo("spm_contacto/search", "Primero") ?></td>
                        <td><?php echo $this->tag->linkTo("spm_contacto/search?page=" . $page->before, "Anterior") ?></td>
                        <td><?php echo $this->tag->linkTo("spm_contacto/search?page=" . $page->next, "Siguiente") ?></td>
                        <td><?php echo $this->tag->linkTo("spm_contacto/search?page=" . $page->last, "ultimo") ?></td>
                        <td><?php echo $page->current, "/", $page->total_pages ?></td>
                    </tr>
                </table>
            </td>
        </tr>
    </tbody>
</table>

This is my controller

<?php
use Phalcon\Mvc\Model\Criteria;
use Phalcon\Paginator\Adapter\Model as Paginator;
class SpmContactoController extends ControllerBase {

    public function indexAction() {

    }
    public function searchAction() {
        $numberPage = 1;
        if ($this->request->isPost()) {
            $query = Criteria::fromInput($this->di, "SpmContacto", $_POST);
            $this->persistent->parameters = $query->getParams();
        } else {
            $numberPage = $this->request->getQuery("page", "int");
        }

        $parameters = $this->persistent->parameters;
        if (!is_array($parameters)) {
            $parameters = array();
        }
        $parameters["order"] = "CONT_CODIGO";

        $SPM_CONTACTO = SpmContacto::find($parameters);
        if (count($SPM_CONTACTO) == 0) {
            $this->flash->notice("El contacto no EXISTE");

            return $this->dispatcher->forward(array(
                        "controller" => "spm_contacto",
                        "action" => "index"
            ));
        }

        $paginator = new Paginator(array(
            "data" => $SPM_CONTACTO,
            "limit" => 10,
            "page" => $numberPage
        ));

        $this->view->page = $paginator->getPaginate();
    }
    public function newAction() {   
    }

    public function editAction($CONT_CODIGO) {
        if (!$this->request->isPost()) {
            print($CONT_CODIGO);
            $SPM_CONTACTO = SpmContacto::findFirstByCONT_CODIGO($CONT_CODIGO);
            if (!$SPM_CONTACTO) {
                $this->flash->error("El contacto buscado no fue encontrado " . $CONT_CODIGO);
                return $this->dispatcher->forward(array(
                            "controller" => "spm_contacto",
                            "action" => "index"
                ));
            }
            $this->view->CONT_CODIGO = $SPM_CONTACTO->CONT_CODIGO;
            $this->tag->setDefault("CONT_CODIGO", $SPM_CONTACTO->CONT_CODIGO);
            $this->tag->setDefault("CONT_CEDULA", $SPM_CONTACTO->CONT_CEDULA);
            $this->tag->setDefault("CONT_RUCIDE", $SPM_CONTACTO->CONT_RUCIDE);
            $this->tag->setDefault("CONT_NOMBRE", $SPM_CONTACTO->CONT_NOMBRE);
            $this->tag->setDefault("CON_ESTADO", $SPM_CONTACTO->CON_ESTADO);
            $this->tag->setDefault("CONT_TELEFO", $SPM_CONTACTO->CONT_TELEFO);
            $this->tag->setDefault("CONT_DIRECC", $SPM_CONTACTO->CONT_DIRECC);
            $this->tag->setDefault("CONT_AREA", $SPM_CONTACTO->CONT_AREA);
            $this->tag->setDefault("CONT_CARGO", $SPM_CONTACTO->CONT_CARGO);
            $this->tag->setDefault("CONT_TIPOXX", $SPM_CONTACTO->CONT_TIPOXX);
        }
    }

    public function createAction() {

        if (!$this->request->isPost()) {
            return $this->dispatcher->forward(array(
                        "controller" => "spm_contacto",
                        "action" => "index"
            ));
        }
        $SPM_CONTACTO = new SpmContacto();
        $SPM_CONTACTO->CONT_CODIGO = $this->request->getPost("CONT_CODIGO");
        $SPM_CONTACTO->CONT_CEDULA = $this->request->getPost("CONT_CEDULA");
        $SPM_CONTACTO->CONT_RUCIDE = $this->request->getPost("CONT_RUCIDE");
        $SPM_CONTACTO->CONT_NOMBRE = $this->request->getPost("CONT_NOMBRE");
        $SPM_CONTACTO->CON_ESTADO = $this->request->getPost("CON_ESTADO");
        $SPM_CONTACTO->CONT_TELEFO = $this->request->getPost("CONT_TELEFO");
        $SPM_CONTACTO->CONT_DIRECC = $this->request->getPost("CONT_DIRECC");
        $SPM_CONTACTO->CONT_AREA = $this->request->getPost("CONT_AREA");
        $SPM_CONTACTO->CONT_CARGO = $this->request->getPost("CONT_CARGO");
        $SPM_CONTACTO->CONT_TIPOXX = $this->request->getPost("CONT_TIPOXX");
        if (!$SPM_CONTACTO->save()) {
            foreach ($SPM_CONTACTO->getMessages() as $message) {
                $this->flash->error($message);
            }
            return $this->dispatcher->forward(array(
                        "controller" => "spm_contacto",
                        "action" => "new"
            ));
        }
        $this->flash->success("El contacto fue guardado con exito");
        return $this->dispatcher->forward(array(
                    "controller" => "spm_contacto",
                    "action" => "index"
        ));
    }
    public function saveAction() {
        if (!$this->request->isPost()) {
            return $this->dispatcher->forward(array(
                        "controller" => "spm_contacto",
                        "action" => "index"
            ));
        }
        $CONT_CODIGO = $this->request->getPost("CONT_CODIGO");
        $SPM_CONTACTO = SpmContacto::findFirstByCONT_CODIGO($CONT_CODIGO);
        if (!$SPM_CONTACTO) {
            $this->flash->error("El contacto no existe " . $CONT_CODIGO);

            return $this->dispatcher->forward(array(
                        "controller" => "spm_contacto",
                        "action" => "index"
            ));
        }
        $SPM_CONTACTO->CONT_CODIGO = $this->request->getPost("CONT_CODIGO");
        $SPM_CONTACTO->CONT_CEDULA = $this->request->getPost("CONT_CEDULA");
        $SPM_CONTACTO->CONT_RUCIDE = $this->request->getPost("CONT_RUCIDE");
        $SPM_CONTACTO->CONT_NOMBRE = $this->request->getPost("CONT_NOMBRE");
        $SPM_CONTACTO->CON_ESTADO = $this->request->getPost("CON_ESTADO");
        $SPM_CONTACTO->CONT_TELEFO = $this->request->getPost("CONT_TELEFO");
        $SPM_CONTACTO->CONT_DIRECC = $this->request->getPost("CONT_DIRECC");
        $SPM_CONTACTO->CONT_AREA = $this->request->getPost("CONT_AREA");
        $SPM_CONTACTO->CONT_CARGO = $this->request->getPost("CONT_CARGO");
        $SPM_CONTACTO->CONT_TIPOXX = $this->request->getPost("CONT_TIPOXX");
        if (!$SPM_CONTACTO->save()) {

            foreach ($SPM_CONTACTO->getMessages() as $message) {
                $this->flash->error($message);
            }

            return $this->dispatcher->forward(array(
                        "controller" => "spm_contacto",
                        "action" => "edit",
                        "params" => array($SPM_CONTACTO->CONT_CODIGO)
            ));
        }
        $this->flash->success("La informacion a sido actualizada correctamente");
        return $this->dispatcher->forward(array(
                    "controller" => "spm_contacto",
                    "action" => "index"
        ));
    }
    public function deleteAction($CONT_CODIGO) {
        $SPM_CONTACTO = SpmContacto::findFirstByCONT_CODIGO($CONT_CODIGO);
        if (!$SPM_CONTACTO) {
            $this->flash->error("El contacto no fue encontrado");
            return $this->dispatcher->forward(array(
                        "controller" => "spm_contacto",
                        "action" => "index"
            ));
        }
        if (!$SPM_CONTACTO->delete()) {

            foreach ($SPM_CONTACTO->getMessages() as $message) {
                $this->flash->error($message);
            }
            return $this->dispatcher->forward(array(
                        "controller" => "spm_contacto",
                        "action" => "search"
            ));
        }
        $this->flash->success("El contacto fue borrado con exito");
        return $this->dispatcher->forward(array(
                    "controller" => "spm_contacto",
                    "action" => "index"
        ));
    } }  

and finally my model

<?php

class SpmContacto extends \Phalcon\Mvc\Model
{
    public $CONT_CODIGO;
    public $CONT_CEDULA;
    public $CONT_RUCIDE;
    public $CONT_NOMBRE;
    public $CON_ESTADO;
    public $CONT_TELEFO;
    public $CONT_DIRECC;
    public $CONT_AREA;
    public $CONT_CARGO;
    public $CONT_TIPOXX;
    public function initialize()
    {
        $this->setSchema("SPOLS");
        $this->setSource("'SPM_CONTACTO'");
        $this->hasMany('CONT_CODIGO', 'SpmReferencia', 'CONT_CODIGO', array('alias' => 'SpmReferencia'));
        $this->hasMany('CONT_CODIGO', 'SptDetalle', 'CONT_CODIGO', array('alias' => 'SptDetalle'));
        $this->hasMany('CONT_CODIGO', 'SptEncabezado', 'CONT_CODIGO', array('alias' => 'SptEncabezado'));
    }
    public static function find($parameters = null)
    {
        return parent::find($parameters);
    }
    public static function findFirst($parameters = null)
    {
        return parent::findFirst($parameters);
    }
    public function getSource()
    {
        return 'SPM_CONTACTO';
    }}

I highly suspected that your issue is due to the same cause as the issue I'm facing, as I posted here: https://forum.phalcon.io/discussion/8411/modelfindfirst-with-conditions-and-always-getting-0-result-on-or



81.1k
Accepted
answer

In the current version already they got this problem solving

git clone  git://github.com/phalcon/cphalcon.git
cd cphalcon/ext
git checkout 2.0.x
sudo ./install(edited)


2.1k

I have the same problem, please let me know how to fix it, i using phalcon 2.0.8 on windows 7. Thanks



81.1k

Please sign in here

https://phalconchats.slack.com/

Seek the help you andresgut with the file so you can upgrade, because what happens to you served in linux but not windows

edited Jan '16

I've got the same problem. I use the 2.0.9 version in Windows 7. In my logger the query is something like this:

SELECT * FROM (SELECT Z1. *, ROWNUM PHALCON_RN FROM (SELECT USERS.ID, USERS.CPF, USERS.PASSWORD, USERS.MUSTCHANGEPASSWORD, USERS.EMAIL, USERS.NOME, USERS.STATUS, USERS.SDEL, USERS.CREATEBY, USERS.CREATEIN, USERS.UPDATEBY, USERS.UPDATEIN FROM USERS WHERE USERS.ID =: 0 USERS.SDEL AND IS NULL) WHERE ROWNUM Z1 <= 0)

This 'ROWNUM <= 0' should come as 'ROWNUM> 1'? Or am I mistaken?