Custom Module Code

I’m new to Yii (couple of months). I have a custom site before Yii, that draws a graphic representation on a canvas object on the screen, using javascript, based on data from several mysql tables. So I started by using Gii to create a custom module.

OK, now I register my js, javascript file, and I want it to grab some values from the web page using the dom. But the scripts are all placed in the header, so they can’t read the DOM yet. My javascript code functions properly, and I can call functions to draw shapes on the canvas. But I’m having trouble just grabbing a value from the HTML.

Question 1. How do you register a custom javascript file so that it is placed in the body. I’m seeing lots of other simple solutions, but within the Yii environment its not always easy to find.

Once I have the key ID from the page, I want to use AJAX and Jquery to get some values from several mySQL tables…so that I can incrementally update the page with the graphics. No way that I can see to do it with the built in models, I have to write my own sql calls.

Question 2: Is this a situation where it is better to use DAO calls,instead of the built in Yii functions? I would rather be able to use the db object in the config file, which works fine in their own models with their one table, but what is the best strategy for doing custom sql searches?

Note: think I’ve found the answer to question 1: parameters of registerscriptfile allows us to change location of the javascript resources.

  1. just add your code to ready() section.

It can be done using POS_READY value.

See this:

(btw I wonder if it’s default value)

  1. Yii already has built-in DAO:

Thank you, I’m working through those now.