Hi Brian,
> YourModel->field(
> 'field_name',
> array('id' => $id)
> )
>
doh! good shout!
--
jon bennett
w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett
--~--~-~--~~~---~--~~
You received this message because you are subscribed
YourModel->field(
'field_name',
array('id' => $id)
)
On Fri, Apr 17, 2009 at 5:32 PM, mattalexx wrote:
>
> Is there any way to recreate something like this?
>
> $result = mysql_query('SELECT single_field FROM table WHERE id = 1
> LIMIT 1');
> $single_field_value_of_record_1 =
>> That returns a record, not one string, right?
>
> if you need a string, write a model method to return it:
except that function will NEVER work cause of a typo! try:
function findFieldValue($field, $conditions=array())
{
if (isset($field) && !empty($conditions))
{
> That returns a record, not one string, right?
if you need a string, write a model method to return it:
// Function in a model or AppModel if required application wide
function findFieldValue($field, $conditions=array())
{
if (isset($field) && !empty($condistions))
{
> That returns a record, not one string, right?
you can use the parameter 'list' with limit = 1:
$single_field_value_of_record_1 = $this->find('list', array(
'conditions'=>array( 'table.single_field'=> 1),
'fields'=>array('single_field'), 'limit'=>1 ));
this should give you an array of size 1.
That returns a record, not one string, right?
On Apr 17, 3:38 pm, fain182 wrote:
> > > $result = mysql_query('SELECT single_field FROM table WHERE id = 1
> > LIMIT 1');
> > $single_field_value_of_record_1 = mysql_result($result, 0,
> > 'single_field');
> > ?>
>
> $single_field_value_of_record_1
> $result = mysql_query('SELECT single_field FROM table WHERE id = 1
> LIMIT 1');
> $single_field_value_of_record_1 = mysql_result($result, 0,
> 'single_field');
> ?>
$single_field_value_of_record_1 = $this->find('first', array(
'conditions'=>array( 'table.single_field'=> 1) ));
the trick is t
Is there any way to recreate something like this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send