PHP PDO CRUD.

PHP PDO CRUD.

jimomakjimomak Posts: 22Questions: 4Answers: 0

I am desperate. I need to perform AJAX jQuery CRUD using DataTables. I use PHP PDO MySQL. There is so much 'disinformation' on the web that I'm confused. Sorry...just being truthful. I know PHP PDO and use a single PHP connection no OOP functions. I follow PDO delusions methods for secure PHP PDO. I do not want to sacrifice security for simplicity...but simplicity is the issue. I can easily render the DataTable hooking it to PHP PDO, but I can't understand the 'success' syntax for rendering the table using AJAX jQuery, Inserting, updating, and deleting. What is being posted on the Web does not make sense, is too obtuse, and mixes up the various methods into an nFactorial of soup. Am I the only one who experiences this 'miasma'? I do not use a framework...just simple PHP PDO and my own CSS.This should not matter...DataTables and jQuery should be independant of frameworks. Thank you.

Replies

  • tangerinetangerine Posts: 3,350Questions: 37Answers: 394

    DataTables' Editor will do this for you.

  • jimomakjimomak Posts: 22Questions: 4Answers: 0

    Thank you Tangerine. I didn't know editor existed. I purchased a license, and now I'm learning how to use it. I owe you one!

  • tangerinetangerine Posts: 3,350Questions: 37Answers: 394

    You're welcome.
    You will find plenty of advice in here if you need it.

  • jimomakjimomak Posts: 22Questions: 4Answers: 0

    File setup. I'm moving the bootstrap css and the js files to create a template using php. I don't see anything on the file structure setup after download. How do I connect the database to the webpage? Normally I use <?php include("includes/init.php") where 'init.php' aggregates any 'common pages' for structure such as functions needed by all pages. I don't see any references to the file structure needed to support webpages. Normally I use css, js, includes, images, documents. All table pages exist under the 'root'. includes holds all php processing pages for CRUD. However with dt, this changes to pages under the root and 'DataTables', but what is referenced to stitch it all together???

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin

    Hi,

    The typical directory structure used with Editor PHP is the same as what you get when you unzip the PHP package. To configure the database connection (PDO) you need to modify the config.php file as described in the getting started instructions.

    You’ll notice that we use a similar directory structure to the one you describe - js / css, etc. You can leave them in a DataTables-Editor directory if you want, or you can move the files from each directory into your own. If you change the path names you’ll need to update the includes (be it the css, js or whatever directories).

    Let me know how you get on with it.

    Allan

  • jimomakjimomak Posts: 22Questions: 4Answers: 0

    I need a 'zoom' session with a human. I will pay for the learning curve. I have so much work and such a steep learning curve that I recognize my position...I have to pay. This framework is not 'making sense to me'. I have 3 years of 'php pdo mysql' non-framework experience, with some JavaScript. I just need some real basic layout and integration help to get started. I live in Seattle time-zone. I can render 'DataTables' using PHP PDO connection, but I don't know how to setup the templates and take advantage of the framework...it just doesn't click.

  • jimomakjimomak Posts: 22Questions: 4Answers: 0

    I can also model MySQL db with complex joins, stored procedures, ect...but how is the db integrated into the framework??? Is this even worth the effort if I can do this outside the framework? I'm not sure.

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin

    Unfortunately, our PHP libraries only support a simple left join and a simple one-to-many join. More complex queries such as right joins, multiple join conditions, sub-queries and stored procedures would be something that would need to be done externally to our libraries.

    What I would suggest is that you try our Generator software which will let you put in a simple table / columns and it will build the HTML/JS/CSS/PHP needed for that table including all the files in the right structure. Hopefully that will help it make sense, particularly as you can modify the inputs easily to see the results on the output code.

    Regards,
    Allan

  • jimomakjimomak Posts: 22Questions: 4Answers: 0

    I will give it a go. This will work when I get the setup correct 99% of the time. I prefer to use the libraries when possible...once I understand the structure. Thank you

  • jimomakjimomak Posts: 22Questions: 4Answers: 0

    Downloaded from the table generator. Progress is being made. I have a db conn and I render JSON to the browser. Now to make it connect to the DataTables libraries to get a real table. I'm still not sure about how the proper file folder structure should be. Does anyone have a .png or .jpg they would share of their structure. That would be worth a thousand words to me.Thank you

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin

    The zip file that Generator downloads contains the typical file structure you might use for Editor with PHP. Does that not show you what you need?

    Allan

  • jimomakjimomak Posts: 22Questions: 4Answers: 0

    I'm getting close..I get JSON data on a page, but without HTML structure...just the array data. I will go through the instructions again...again. I can make it all work and render 'external' to your libraries. It is using the templates provided, to initial the library structure that I don't understand...gluing it together with 'includes' on the pages so that the internal libraries function...for it is the CRUD AJAX functionality that is the attractor to DataTables. Without the internal libraries what's the point. I'm 10 days into experimenting with no results.

  • jimomakjimomak Posts: 22Questions: 4Answers: 0

    Unfortunately for me, I am reading the documents and I have the table being recognized without data...using the 'libraries'. I have no problem using freeform PHP PDO MySQL to render data to the table...this is easy. I do not understand the 'templates' to initialize the 'DataTable' Editor, to render tables..or even how to build a table, and then where to put the php template if such an item exists. Just reading is not cutting it for me, sadly. I will pay for a 'live session' if such a person exists on Zoom or Skype, or similar session media to actually show me how configure the libraries. I only need to see it once...but reading about the engineering details does not translate into functional instructions. Sorry.

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin

    Hi,

    Have you used Generator? And did you upload the generated files to your server? And did they work? That is the place to start. It doesn't do anything fancy, it just includes the minimum amount of code needed to get started.

    Let's start from there and build up to more complex applications.

    If you are having problems with the Generator produces tables, let's resolve that first. If you are, please detail what those issues are.

    Allan

This discussion has been closed.