No records found ... Agiletoolkit and Oracle. Grid / CRUD elements
I am trying to test Agile Toolkit with oracle by setting a model and trying to show a grid that says "No records found" ...
Let me tell you what I did as I was guessing most of the config since I couldn't find any guides for oracle.
-
My Oracle connection string in agiletoolkit config-default.php looks like this:
$ config ['dsn'] = array ('oci: dbname = localhost / MYDATABASE', 'MYUSER', 'MYPASSWORD');
-
To fix the driver not found error, I have enabled
extension=php_pdo_oci8.dll
in php.ini file from apache installation. -
Then there was an error regarding the missing "oci.php" to decide that I had to create my own file like this:
class DB_dsql_oci extends DB_dsql { function limit($cnt,$shift=0){ $cnt+=$shift; $this->where('NUM_ROWS>=',$shift); $this->where('NUM_ROWS<',$cnt); return $this; } function render_limit(){ return ''; } }
and put it in: ...atk4\lib\DB\dsql
- To fix the special characters error from oracle, I set line 59 to / atk 4 / lib / DB / dsql.php for an empty line like this:
public $bt='';
I was able to run a database test and it says "Successfully connected to the database".
Then I created the model "lib \ Model \ Mytable.php" as follows:
<?php
class Model_Mytable extends Model_Table {
public $table = "MYTABLE";
function init(){
parent::init();
$this->addField('ID');
$this->addField('NAME');
$this->addField('INIDATE');
$this->addField('ENDDATE');
}
?>
After that I created a new page and tried to use the model like this:
<?php
class page_test extends Page {
function init(){
parent::init();
$form = $this->add('Grid');
$form->setModel('Mytable');
}
}
?>
After refreshing the browser, it will display a grid that says "No entries"
I wonder what happens, that there are no records in the table, all data is committed, and I'm sure oracle is processing the requests because if I miss the column name the error in oracle will go up.
Any hint?
source to share
This is how you can simply set DSQL as the View (Grid) data source:
class page_test extends Page_Basic
{
function init()
{
parent::init();
// DSQL
$q = $this->api->db->dsql();
$q->table('MYTABLE')
->field('DNAME')
->field('INIDATE');
// Create grid and set DSQL as its data source
$g = $this->add('Grid');
$g->addColumn('DNAME');
$g->addColumn('INIDATE');
$g->setSource($q);
// better add paginator too or your grid can become huge :)
$g->addPaginator();
}
}
source to share