Set permissions to specific node in php
Content Access


  This module allows you to manage permissions for content types by role
  and author. It allows you to specify custom view, edit and delete
  permissions for each content type. Optionally you can enable per
  content access settings, so you can customize the access for each
  content node.


Nodeaccess


  Nodeaccess is a Drupal access control module which provides view, edit
  and delete access to nodes. Users with the 'grant node permissions'
  permission will have a grant tab on node pages which allows them to
  grant access to that node by user or role. Administrators can set
  default access controls per content type, and also define which roles
  are available to grant permissions to on the node grants tab.


If you want to add it by custom code use hook_node_access

function mymodule_node_access($node, $op, $account) {
  // We are interested to existing objects. When the node is being created, Drupal passed the node type instead of the node object. 
  if (is_object($node)) {
    $check = (
      ($node-&gt;type == 'node condition')         );
    if ($check) {
      if ($account-&gt;uid == $node-&gt;uid) {
        return NODE_ACCESS_ALLOW;
      }
      else {
        return NODE_ACCESS_DENY;
      }
    }
  }

  return NODE_ACCESS_IGNORE;
}