change status when value does not exits in column

I Need bellow code in phalcon php

  • $mysqli = new mysqli(SERVER, DBUSER, DBPASS, DATABASE);
  • $result = $mysqli->query("SELECT id FROM mytable WHERE city = 'c7'");
  • if($result->num_rows == 0) {
  • // row not found, do stuff...
  • } else {
  • // do other stuff...
  • }
  • $mysqli->close();
edited Aug '17

When using a model just do

$result  = Table::findByCity('c7');
if(!$result) {
    // result will be NULL if not data was found show 404page or handle otherwise
}

// result is a populated Table do what you want with the data

more info https://docs.phalconphp.com/es/3.2/db-models

Other useful phalcon docs:

https://docs.phalconphp.com/es/3.2/db-phql

https://docs.phalconphp.com/es/3.2/db-odm