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

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.phalcon.io/es/3.2/db-models

Other useful phalcon docs:

https://docs.phalcon.io/es/3.2/db-phql

https://docs.phalcon.io/es/3.2/db-odm