Thanks @wendybeth010 for your blog notes on the first chapter. A few initial responses that wouldn't fit into a tweet:
Had to restart Apache server in order for pages to load
Interesting. This is usually only required if Apache configuration has changed. I'll have a think about what that could be...
Could not create new folder with @touch, and the description ‘being disallowed by file system permissions’ did not help me to figure out how to fix the issue
Pleased your search-fu got you going again! The problem is that the web server (Apache) runs as a different user to your user account, and so extra permissions are required to say it's OK for the server to write to your folder.
I have a bug report to consider switching to PHP's build-in test server, which just uses your user account - and so no permissions need to be reset.
It’s the next sentence [about PDO, from the PHP manual] that really baffles me
Yes! The PHP manual is extremely detailed and useful, but sometimes the programmers writing the docs write like, well, programmers.
Here's a couple of bits of database code I think I didn't explain sufficiently:
// Run some SQL e.g. create a table
$pdo = new PDO($dsn);
$result = $pdo->exec($sql);
// Run a query and fetch a result
$sql = "SELECT COUNT(*) AS c FROM post";
$stmt = $pdo->query($sql);
$count = $stmt->fetchColumn();
From your notes:
$sql is the contents of the database
In the installer, that's correct - this contains the SQL commands to create the database from scratch. In general, I use
$sql to hold SQL commands to run. The
exec is just a way to "execute" (run) the commands.
$pdo is using $dsn to find the database
Absolutely right. The DSN describes what server to find the database on, what the username/password is, and what format it is in (SQLite in our case).
$pdo is an variable created from the
PDO class - this is an example of "object orientation", which you may have heard of. It's a useful way of organising and thinking about code. The
PDO class acts like a template, and the variable created with new is a copy of that template.
query() on the PDO object you already have - which is handy, as it means you don't need to set up that connection to the database again. The call returns another object type, a
PDOStatement, which is used to contain results (and we store that in variable
Based on your feedback I will try to add some more detail about how database access works, but I am rather cautious about flooding the reader - how objects work should probably be skipped over by beginner coders. Your approach of regarding some parts as "Witchcraft!" is actually a good idea - as you get more comfortable with this sort of material, your brain will start to fill in the blanks.
I am hoping to add feedback tools directly to the tutorial, so people can ask questions exactly where they don't understand something. That won't be done in a few days though, as getting the user interface right will be tricky. But, for the general problems you raise, I do think it will be useful. Watch this space!
And thanks again for your feedback - more the merrier.