Alex J Tue Feb 04 14:19:39 -0500 2014

Subject: ::find(1) not working

Hello,
::find() does not work to find by id, as the documentation says.
see this simple code :

$id = $_GET['id'];
if($var = Model::find($id) ) {echo 'this is ::find() working well!';} //this does not output nothing, blank, turns FALSE?

if($var = Model::find_by_id($id) ) {echo 'this is ::find_by_id() working well!';} //this outputs correctly!

##############################

::find() and find_by_id() boolean issues?

please help
-----As a joke i would say that ::find() is bipolar :) haha ...just joking


Alex J Tue Feb 04 17:11:18 -0500 2014

Problem solved, i just use ::exists... as follows : ** I hope this helps someone solve how to check with phpactiverecord, how to verify if record exists by query : with a nice Boolean true/false return, perfect for if () {}...

 1 # inclue the ActiveRecord library
 2 # require_once 'php-activerecord/ActiveRecord.php';  .....................as usual....
 3 
 4 if (Soccer_game_stat::exists(array('seasonid' => $gamecalendar->seasonid , 'teamid' => $gamecalendar->teama ))  ) 
 5 {
 6       echo 'yes it exists';
 7 
 8      }
 9 else
10 {
11  //echo 'does not exist';
12 }
13 
Alex J Tue Feb 04 17:13:39 -0500 2014

As seen on the docs :
SomeModel::exists(123);
SomeModel::exists(array('conditions' => array('id=? and name=?', 123, 'Tito')));
SomeModel::exists(array('id' => 123, 'name' => 'Tito'));

url: http://www.phpactiverecord.xyz/docs/ActiveRecord/Model

(1-2/2)