Problem connecting with database
Problem connecting with database
Somebody please help me, I need to connect my database with the datatables, but it returns a problem with ajax. What files do I have to modify to get my database connected? This is what I have, it was generated automatically, I also generated JS and html files, so I suppose thats not where the errors are, do I have to modify it?
/*
* Editor server script for DB table estoque
* Created by http://editor.datatables.net/generator
*/
// DataTables PHP library and database connection
include( "lib/DataTables.php" );
// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Upload,
DataTables\Editor\Validate;
// The following statement can be removed after the first run (i.e. the database
// table has been created). It is a good idea to do this to help improve
// performance.
$db->sql( "CREATE TABLE IF NOT EXISTS estoque
(
Est_Produtos_CodProduto
int(10) NOT NULL auto_increment,
est_quantestoque
numeric(9,2),
est_data_hora
datetime,
PRIMARY KEY( Est_Produtos_CodProduto
)
);" );
// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'estoque', 'Est_Produtos_CodProduto' )
->fields(
Field::inst( 'est_quantestoque' ),
Field::inst( 'est_data_hora' )
->validator( 'Validate::dateFormat', array( 'format'=>'Y-m-d H:i:s' ) )
->getFormatter( 'Format::datetime', array( 'from'=>'Y-m-d H:i:s', 'to' =>'Y-m-d H:i:s' ) )
->setFormatter( 'Format::datetime', array( 'to' =>'Y-m-d H:i:s', 'from'=>'Y-m-d H:i:s' ) )
)
->process( $_POST )
->json();
Answers
Have you revised DataTables.php to show your correct db connection details?
What does the "problem" say?