Get KoolPHP UI with 30% OFF!

KoolGrid CodeGenerator

Michael
Hello,
I am playing around with the code generator for KoolGrid. I am a new to koolphp
The generated code gives me an error:
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead...
This is the generated code:
<?php 
    /*
     * Please put this file in the same folder with KoolControls folder
     * or you may modify path of require and scriptFolder to refer correctly
     * to koolgrid.php and its folder.
     */
    require "KoolControls/KoolGrid/koolgrid.php";
 
    $db_con = mysql_connect("localhost","sakila","caroline");
    mysql_select_db("sakila",$db_con);
 
    $ds = new MySQLDataSource($db_con);
    $ds->SelectCommand = "select actor_id, first_name, last_name from actor";
    $ds->UpdateCommand = "update tblUsers set name='@name' where id='@id'";
    $ds->InsertCommand = "insert into tblUsers(id,name) values('@id','@name')";
    $ds->DeleteCommand = "delete from tblUsers where id=@id";
 
    $grid = new KoolGrid("grid");
    $grid->scriptFolder = "KoolControls/KoolGrid";
    $grid->DataSource = $ds;
 
 
    $column = new GridBoundColumn();
    $column->DataField = "actor_id";
    $grid->MasterTable->AddColumn($column);
 
    $column = new GridBoundColumn();
    $column->DataField = "last_name";
    $grid->MasterTable->AddColumn($column);
 
    $column = new GridBoundColumn();
    $column->DataField = "first_name";
    $grid->MasterTable->AddColumn($column);
 
 
    $grid->Process();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>KoolGrid</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    </head>
    <body>
        <?php echo $grid->Render(); ?>
    </body>
</html>

Can anybody advice please?
Posted Jun 30, 2016 Kool
Igor
Hi,
replace
 $db_con = mysql_connect("localhost","sakila","caroline");
mysql_select_db("sakila",$db_con);
$ds = new MySQLDataSource($db_con);

with:
		
$DB_HOST = 'localhost'; //Host name<br>
$DB_USER = 'xxx'; //Host Username<br>
$DB_PASS = 'xxx'; //Host Password<br>
$DB_NAME = 'xxx'; //Database name<br><br>
$ds = new PDODataSource(new PDO ("mysql:host=$DB_HOST; dbname=$DB_NAME;", $DB_USER, $DB_PASS, 
array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"))); // PDO Connection
Posted Jul 1, 2016 Kool
Michael
Hi Igor,
When I replace this, I am getting an error:
Class 'PDODataSource' not found
However, phpinfo() shows that PDO is there.
Please advice,
Michael
Posted Jul 1, 2016 Kool
Igor
Check for PDODataSource.php file in KoolPHPSuite/KoolControls/KoolGrid/ext/datasources folder .
Posted Jul 1, 2016 Kool
Michael
This file exists in this folder, and I added the third line and it works. :)
include "KoolControls/KoolGrid/koolgrid.php";
    include "KoolControls/KoolAjax/koolajax.php";
    include "KoolControls/KoolGrid/ext/datasources/PDODataSource.php";
Posted Jul 1, 2016 , edited Jul 1, 2016 Kool