pdoExec() function

for non-crud SQL statements (maintenance),  returns affected rows

  • custom  insert, update, delete   statements
  • typically execute in the Model Class

Parameters - pdoExec( sql )
  1. SQL - custom sql statement
    
    // Example 1   [models/controller] - PHP pdoExec function
    //    Note: $this->db - database connector inside the model class

    function deleteClients( $state) {
        $orgid =  Session::get('orgid');

        $SQL = "DELETE *
                FROM clients  c
                WHERE c.orgid = {$orgid}
                AND   c.state = '{$state}' ";

        $count = $this->db->pdoExec($SQL);
        return $count;
    }