Menu
  • HOME
  • TAGS

PHP Active Record: Multiple has many associations

php,mysql,database,phpactiverecord

Your first definition looks wrong I think: $has_many should be an array of arrays, not an array of array of arrays. You have this in your single-has-many example with only students, but in your first example you've added an array. so this works indeed: static $has_many = [ [ 'subjects',...

Setting up models with left joined tables in PHPActiveRecord

sql,phpactiverecord

As far as I know, phpactiverecord does not support composite primary keys, so for some functionality you might want to define a seperate key anyway. Further: the statuscolumn would not be unique in this case? There could be multiple btable_id entries for your atable_id, so there would not be a...

PHP ActiveRecord last_query not filling in?

php,activerecord,phpactiverecord

last_query is the raw SQL. PHP ActiveRecord is using PDO's prepared statement so you won't see the actual query. What you should do is using a logger. The values will be shown there (the code). $log = Log::singleton('file', 'my.log'); //using PEAR Log ActiveRecord\Config::instance()->set_logging(true); ActiveRecord\Config::instance()->set_logger($log); Example from: http://www.phpactiverecord.org/boards/4/topics/1119-re-show-last-sql-query...

Phpdoc documentation with php activerecord

php,activerecord,orm,phpdoc,phpactiverecord

You can document all your "magic" properties as an @property! Say you have a table "Company" with fields "id, name, location", you would end up with: ** * @property int $id * @property string $name * @property string $location */ class Company extends \ActiveRecord\Model { } You can see in...

string converted to int is too large

php,mysql,phpactiverecord

Your BIGINT is being cast to an int because of the setting in column.php. While the "real solution" would be to run a 64 bit system, if you cannot, the other thing might be to just stop the cast from happening Look at line 37 in column.php , I suggest...

Check NULL value using PhpActiveRecord

php,mysql,phpactiverecord

Well after spending ... all day, I have found a solution. I suppose it might have been common sense but it was not in the documentation so I had to guess. Apparently you can simply say 'is null' in the condition string like regular SQL and it will work... That...

Yii 1.x, query in query DB selection

php,yii,phpactiverecord

Assumptions: tbl_role has a model named Role tbl_user_role has a model named UserRole tbl_user_role_request has a model named UserRoleRequest Note that this will do 3 seperate queries but I believe this is the closest you can get without creating a total mess. <?php $userId = 35; $roles = UserRole::findAllByCondition(array('userId' =>...