169 questions
0
votes
1
answer
349
views
php-activerecord is not working in PHP 8.2 with Codeignitor
We developed a CodeIgniter application using the PHP ActiveRecord ORM for the Query builder, and the application runs in a Docker container on an AWS server.
We recently upgraded PHP from version 8.0 ...
0
votes
1
answer
407
views
How to convert object to array in php active record
I am using phpactive record. To find all data from one table I am using like below
$groups = GroupModel::all();
echo "<pre>";
print_r($groups);
then getting output like
Array
(
[0] =>...
0
votes
0
answers
97
views
Use named placeholders in PHP ActiveRecord
I'm working on a API with FlightPHP and PHPActiveRecord that returns an array of Reports optionally filtered through url query string parameters.
$allowed = ['author' => 'author_id', 'owner' => ...
2
votes
1
answer
515
views
Cannot get property from object $this variable
I really confused with the situation. I want to get data from function in my class, that created by ActiveRecord Model. Here a class:
class Bag extends ActiveRecord\Model {
static $table_name = "...
1
vote
0
answers
58
views
Codeigniter - setting dbprefix triggers [Cannot modify header information - headers already sent]
I am appending custom selects and table aliases into the query.
Used {PRE} to append prefix to table names in the custom query but it was also adding the prefix to alias in select. if I add
{PRE}...
1
vote
0
answers
77
views
PHP ActiveRecord, Has many with custom keys
I have the following table schema ( legacy system so I can't change it :-( )
admins:
admin_id
...
admin_auths:
admin_id ( connects to admin_id )
id ( connects to user_id )
auth ( only care ...
0
votes
0
answers
37
views
count rows in each group
How would one implement count with a group by operation using the PHP activerecord ORM? I know that I can do this directly via custom_sql, but I am looking for a way to do this more directly through ...
2
votes
1
answer
331
views
Instantiating ActiveRecord models without a database connection
I'm currently in the process of replacing a self-made hack-y MVC approach's Model component with php-activerecord. I have a separate page that displays in the event that the database server goes down, ...
1
vote
1
answer
55
views
When I call row in codeigniter Am I using limits?
I am working in a legacy system that uses row() plus limit() to get one result. I didn't understand why, because row() already give me one result, but a coworker said that improves performance. ...
0
votes
1
answer
70
views
An array of conditions for phpactiverecord
I have so many combinations of conditions that could possibly go into a db call that I can't possibly make a separate call for each one. I'd have way too many if/else statements.
So I wanted to ...
0
votes
3
answers
365
views
PHPActiveRecord validates_uniqueness_of not working
I am currently getting the following error in my User model.
Slim Application Error
The application could not run because of the following error:
Details
Type: ActiveRecord\...
1
vote
1
answer
212
views
Codeigniter - Sparks to composer, activerecord issues now
So I have just gone through a update going from CI 2.0.4 to 3.1.4 and ran into the issue with Sparks now being redundant I've had to move onto composer to get php active record working..
however I ...
0
votes
1
answer
182
views
eloquen and php active record cant find table because additional table suffix 's'
i just get php active record or eloquen from laravel
running on codeigniter. first attempt create model it's run well, but after that i got this following error:
Type: Illuminate\Database\...
1
vote
1
answer
409
views
php activer record Uncaught ActiveRecord\ActiveRecordException Class not found
I have a file index.php and in the same level I have a folder called models where I have my user model User.php
I am trying to user php active-record library, so I downloaded the library and put it ...
1
vote
2
answers
70
views
Concat String to a number returns zero
I'm having a table whith 'id' as pk of type int.
When I'm doing the folowing mysql query in php activerecord
Location_cat::find_by_sql("select concat('#',id) as 'id', text FROM location_cat");
it ...
0
votes
1
answer
38
views
redirect deleted products from database asigning them a new ID
I need to make some redirects for some products which has been deleted from database.
I get the product from database this way:
public function show( $prod_id=null){
$produs=Product::find(...
0
votes
1
answer
70
views
php active record :: 2000, 1066, Not unique table/alias: 'category'
I got 2000, 1066, Not unique table/alias: 'category' this error. I very well know what the issue.
My Code :
static $belongs_to = array(
array('Parent',
'foreign_key'=>'...
0
votes
2
answers
468
views
specifying database on select statement is not working in MySQL View
SELECT `db_name`.`view_name` . *
FROM `db_name`.`view_name`
Above query statement for View is not working.
Below error occurred.
#1051 - Unknown table 'view_name'
Below query statements for Table ...
1
vote
0
answers
73
views
How to set float column value with php activerecord?
I have a table column
price FLOAT(10, 2) NOT NULL DEFAULT 0.00
And Model:
class Mytable extends \ActiveRecord\Model{
static $table_name = 'my_table';
}
In php i use
$price = 23.54;
$obj = new ...
2
votes
1
answer
491
views
How to get an attribute value as Model instance in PHP ActiveRecord?
I am trying to achieve something that should be simple but seems impossible in PHP ActiveRecord.
In the simplified example I created, I have two models, Person and Exchange, and two tables, people(id,...
0
votes
1
answer
39
views
Retrieving data from the table linking linking tables in PHPactiverecord
I have three tables, and I am using members to find all the tasks they have completed.
class Task extends BaseModel {
static $has_many = array(
array('members', 'through' => 'member_tasks'),
...
1
vote
1
answer
398
views
PHP Active Record: Multiple has many associations
I have a database setup with a students table. The students table has a one to many relationship with a few other tables. ie a student can have multiple subjects. but also a student can have multiple ...
0
votes
0
answers
2k
views
Incorrect datetime value on TIMESTAMP column
I have a mysql (version 5.6.24) with a table where one of the columns updated_at is a TIMESTAMP default CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP.
I never needed to worry about this column as ...
1
vote
3
answers
776
views
Can not update php activerecord: model is read-only
I'm trying to update the user details table using php activerecord but everytime I get this error
::save() cannot be invoked because this model is set to read only
I can insert to the same table ...
1
vote
1
answer
288
views
Check NULL value using PhpActiveRecord
According to the documentation here (http://www.phpactiverecord.org/projects/main/wiki/Finders)
There is a way to find records in the database like so below.
# fetch all lousy romance novels which ...
2
votes
2
answers
235
views
string converted to int is too large
I'm using php-activerecord to manage my MySQL entries.
The block of code where the problem ocurs is the following:
$item->id = $result->id;
$item->save();
var_dump($result->id); // ...
12
votes
6
answers
2k
views
PHP activerecord mysql server has gone away
I'm using php-activerecord for a short while now and i absolutely love it. Php-activerecord is an open source ORM library based on the ActiveRecord pattern. However, i recently tried to use it in ...
1
vote
1
answer
295
views
Phpdoc documentation with php activerecord
I'm using php-activerecord for a short while now and i absolutely love it. Php-activerecord is an open source ORM library based on the ActiveRecord pattern. However, i also like phpdoc and use that to ...
0
votes
0
answers
258
views
Convert military time to standard time in sql query
I have my php active record with the code like this:
$app->get('/dailyReservationReport/request', function ($id=null) {
$status_code = 200;
$resp = array('status'=>'success','message'=>'...
1
vote
1
answer
1k
views
CodeIgniter Active Record method chaining with update not working [duplicate]
I'm trying to use Active Record methods to update a table and flag a task as complete like this:
$this->db->update('tasks', array('status' => 'complete'))
->where('id', $...
0
votes
1
answer
1k
views
Cannot display blob image from database using PHP
I am not able to get my broswer to display an image from the database(stored as blob). I have tried
header("Content-type: image/jpeg");
echo '';
But it is still not able to display on the browser.
...
0
votes
1
answer
548
views
PHP Active Record Memcached
How to use phpactiverecord memcached? anyone can help me?
$database = array(
'connection' => 'local',
'local' => 'mysql://username:password@localhost/database?charset=utf8',
'...
0
votes
1
answer
986
views
PHP ActiveRecord Datetime Format
I had a small problem when using PHP ActiveRecord, every project i always change 3 file :
Column.php, Model.php, Connection.php and replace Y-m-d H:i:s T to Y-m-d H:i:s
How to change it easy ?? ...
1
vote
1
answer
221
views
How to use environment variable effectively
So I use two main libraries for PHP project right now: php-activerecord and slim micro framework. I am also a user of vagrant and puppet cause I like keeping thing in sync. The one thing with this ...
0
votes
1
answer
411
views
how do i delete child objects in php activerecord in codeigniter
I am using php-activerecord in my Codeigniter project, I have a 2 tables in my database, questions table and answers table associated in a One to many relationship, When I delete a question like this
...
0
votes
1
answer
203
views
PHP ActiveRecord - Assosiation doesn't work
I just started to use the PHP ActiveRecord class and get along with it quiet well but now I'm stuck by trying to associate a user with a group, and a group with many users.
This is what I've got:
...
0
votes
1
answer
97
views
PHP Active Record using NOW() in condition
I'm trying to find all rows that have an end_time greater than the current time. In MySQL I believe I can use:
SELECT * FROM Table WHERE end_time > DATE(NOW());
So, I'm trying to use:
$options = ...
1
vote
1
answer
61
views
PHPActiveRecord allow_blank, allow_null not working on validations
I have the following validator function.
static $validates_size_of = array(
array('contactfirstname' , 'within' => array(1,50), 'allow_null' => true),
array('contactlastname'...
0
votes
1
answer
546
views
Slim Framework / php active record / twig conundrum, find all where field not equal to
Trying to get to grips with slim framework and phpactive record. Have searched the docs, here and google to no avail and tried several things.
I would like to retrieve all items from a table where a ...
0
votes
1
answer
45
views
Is there any way to reference $this inside an association's conditions?
Let's say I have a Screenshot model with a date column which defines when the screenshot was taken. I also have a GameVersion model with start_date and end_date instance methods defining the beginning ...
0
votes
1
answer
723
views
PHPActiveRecord Find Column Names & Types & In Particular ENUM Components
Is there a way to get all the column names, and then figure out what type the column is? For example, ENUM, VARCHAR, TINYINT, etc..., in particular for ENUM the different components of the ENUM?
I ...
0
votes
1
answer
834
views
phpexcel - how to get all values from resultset in a loop fromarray
I can't figure out how to get all datas (rows and columns) from a mysql resultset.
With this code i get not all rows from the my query :
$row=1;
$column = 'A';
$sql = "SELECT distinct c.code, p....
0
votes
1
answer
374
views
Transform SQL Query to PHP Activerecord
I am trying to transform my sql query in a phpactiverecord query. But it doesn't works. I get this error message:
Fatal error: Uncaught exception 'ActiveRecord\DatabaseException' with message '...
0
votes
1
answer
64
views
Is it possible to multipurpose a Twig template?
I am learning to use Slim framework and Twig. I want to know if it is possible to kind of multi-purpose a template.
Consider this; I want to make a form to add a job for a client, if you access via ...
1
vote
0
answers
134
views
PHP Active Record Update Relation Table
This is my many to many relation
class Post extends ActiveRecord\Model {
static $table_name = 'app_post';
static $has_many = array(
array('postcategory'),
array('category', '...
0
votes
1
answer
319
views
Can't figure out how to associate tables with php active record
I must be missing something important but I can't sort this thing out
I would like to associate many addresses to a person so ... here we go with my settlement:
Is there anyone to help?
CREATE TABLE `...
1
vote
1
answer
660
views
PHP Active record - how to add not in condition in all() function
Can anyone please tell me what is the problem in using the not in condition in the following code:
$filter=implode(',',array(1,2));
$list = static::all(array('conditions' => array('org_grp_id = ? ...
0
votes
1
answer
70
views
Setting up models with left joined tables in PHPActiveRecord
I'm trying to figure out how to model the following in PHPActiveRecord, but am getting stuck and wanted to see if someone could help me out. I'll use a simplified example:
Table List:
atable (id [PK]...
1
vote
1
answer
392
views
PHPActiveRecord group option breaks count function
I have a PHP ActiveRecord model in which I have a function that requires the number of rows a query will return. I obtain the number of rows using the built in static::count($conditions) function. ...
1
vote
0
answers
61
views
Insert error when sending post array to activerecord
I am using CodeIgniter + phpActiveRecord. I am getting all the records from the $_POST array and I want to send that same array to my activeRecord class to insert the data into the DB.
This line ...