Error connecting to db



I trying to do a first connection a bd, but I receive this error. What I need to do to fix this error?

Fatal Error
atk4\core\Exception: Method is not defined for this object

Exception Parameters
• class: “atk4\ui\App”
• method: “dbConnect”
• arguments: [“mysql://root:@localhost/ait”]

This is my code:


require 'vendor/autoload.php';

$app = new \atk4\ui\App('Database');

$db = $app->dbConnect('mysql://root:@localhost/ait');

class entidad extends \atk4\data\Model 
    public $table = 'entidad';
    function init() {

$entidad = new entidad($db);

$table = $app->add('CRUD');



Hi. This was a fix in the pipeline for 1.4.1 version of Agile UI.

I have updated with this version now, so you can either re-download or run “composer update” in a command-line.


Hi Romanish,

it works, but give a new error

Fatal Error
atk4\dsql\Exception: DSQL got Exception when executing this query

Exception Parameters
• error: “SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘id’ in ‘field list’”
• query: “select id,conent,noment,ap1ent from entidad limit 0, 1”

But, in my select, I don’t have any id column.

Can you help me?



Agile Data is a persistence mapper - it maps your object to records in the database. In order to be able to save results, in requires it to have unique id field.

if that field is named differently, not id you can specify its name in id_field property, however you need one. There is a way to disable id but it only makes sense if you are aggregating data. This was introduced in Agile Data 1.2 (


thanks id_field works!


when I try to Add with the Add Button, don’t works. Thw modal window appears with info, and works as Edit Mode, I think.


Something wrong with my code?


yes, remove “loadAny”.

Actually CRUD should probably unload this during add (


Gustavo, are you following the udemy tutorial? where did this line come from?


Yes, I looking Udemy course. I have a new problem, I have several columns thats show fine in the grid, but in the modal view to add, only appears the two original fields, with I began my example code. ie. in the code you see noment and ap1ent (I delete conent, because is the id), later I add some fields more, but only appears noment and ap1ent in the modal window. :frowning:


Gustavo, I’m not sure what could be the problem.

Try to see how those new fields are different to noment try changing things around. If you are stuck, post your code here again.

BTW - what do you think about udemy course so far?


OK. I’m lost :frowning:
The course is very good, easy to understand. :wink:

My actual code:
require ‘vendor/autoload.php’;

$app = new \atk4\ui\App(‘Database’);
//$app = new App(‘My App’);

$db = $app->dbConnect(‘mysql://root:@localhost/ait’);
class entidad extends \atk4\data\Model
public $table = ‘entidad’;
public $id_field = ‘conent’;
function init() {

// $this->addfield(‘conent’);


$entidad = new entidad($db);


$table = $app->add(‘CRUD’);


I comments the LoadAny()

I delete my example data then the grid is empty. First Image.

Then try to add, and only appears two fields with some old data. Second Image.

And because I need to put some data in other fields I can’t add any register, because of data restriction controls.


please clean yoru post, can’t read…


I clean it :slight_smile:


Hi, I’m following the Udemy course, I have Agile Toolkit 1.5.1 installed

in topic 5. Building User Admin page with CRUD, MySQL, Forms and Tables

I try to make a first connection to bd, but I get this error. How can I correct this error?

Fatal Error
atk4\core\Exception: Method is not defined for this object

I can not solve it and would like to continue the course
Thank you


As per error, something is wrong on line 46 of your index.php. In your screenshot there are only 36 lines visible.


the error seems to be in the method: “dbConnect”
I can not show the results table


just delete line 22, you are already connecting on line 12.

I’m not sure where is this line from.


when commenting on line 22 the errors continue


did you modify it? looks like you have addField() instead of $this->addField()