find() public method

Find and load a single record based on the provided key values
public find ( array | mixed $keys = null ) : static
$keys array | mixed An optional primary key value to load the row by, or an array of fields to match. If not set the "id" state variable or, if empty, the identity column's value is used
return static Self, for chaining
コード例 #1
0
ファイル: DataController.php プロジェクト: akeeba/fof
 /**
  * Gets the list of IDs from the request data
  *
  * @param DataModel $model      The model where the record will be loaded
  * @param bool      $loadRecord When true, the record matching the *first* ID found will be loaded into $model
  *
  * @return array
  */
 public function getIDsFromRequest(DataModel &$model, $loadRecord = true)
 {
     // Get the ID or list of IDs from the request or the configuration
     $cid = $this->input->get('cid', array(), 'array');
     $id = $this->input->getInt('id', 0);
     $kid = $this->input->getInt($model->getIdFieldName(), 0);
     $ids = array();
     if (is_array($cid) && !empty($cid)) {
         $ids = $cid;
     } else {
         if (empty($id)) {
             if (!empty($kid)) {
                 $ids = array($kid);
             }
         } else {
             $ids = array($id);
         }
     }
     if ($loadRecord && !empty($ids)) {
         $id = reset($ids);
         $model->find(array('id' => $id));
     }
     return $ids;
 }