Find Function

The find() function has the following parameters:

  • string $conditions
  • array $fields
  • string $order
  • int $recursive

Returns the specified (or all if not specified) fields from the first record that matches $conditions or FALSE if no data is found. Recursive must be -1 to not return any associated data.

Example:

$one_row = $this->ModelName->find('id = ' . clean_id,  null, null, -1);

Return example (i.e. value in $one_row):

Array
(
    [ModelName] => Array
        (
            [id] => 1000
            [name] => Ford
            [status] => A
            [created] => 2007-08-04 00:42:17
            [modified] => 2007-08-04 00:42:17
        )

)

So to get the value of name to your view you could write:

$this->set('name', $one_row['ModelName']['name']);
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: