You will need to have a database that has a site context. This isn't hard. Have a table with an entry for each site. ID|Site Name
Then, in user tables, article, tables, page tables, etc... you can have a column that specifies the site context using the ID in the first table. This way each site can be configured with an ID, and all queries automatically use this id, to get content for their site only.
So a single DB is not hard.
Sharing the code base is also simple. So long as you update the code base generically, and make sure core code stays site agnostic, you can easily copy the same framework to each site, and then easily update each one with updates. Since core code is site agnostic, you can easily patch your framework, without overwriting any site specific settings/code.
Hope this helps.
EDIT:
If one single code base is a must, then you need a catch at the beginning of every request to see what domain is being called, and then set the site ID accordingly. This way everything else will use that site ID to run queries, load styles, views, etc...
However, being in the web industry for over a decade, and specializing in custom built CMS system, I strongly recommend you do not opt for a solution that uses the exact same code for different websites.
It makes debugging harder, and it makes bugs in your code more potentially catastrophic. It also makes hacking your system a breeze and a bigger target since someone can simultaneously take down 12+ sites by hacking one code base.
What you want to do can be done, but I would recommend not doing it.