Tag Archives: MySQL

Odd Magento / Fishpig / WordPress error

If you get an error like:
Fatal error: Call to a member function select() on a non-object in /home/username/public_html/app/code/community/Fishpig/Wordpress/Model/Resource/Page.php on line 119

Then, check you’ve not just changed a MySQL username, without updating the fishpig configuration, or otherwise Fishpig can’t access the MySQL database for some reason. It seems to store a MySQL login in Magento config. I’ve not yet found exactly where, I’ll update this post with more once I understand more about what it’s doing.

 

It presented as the main Magento site throwing the following error:

exception ‘Zend_Exception’ with message ‘dbModel read resource does not implement Zend_Db_Adapter_Abstract’

 

Which it seems that most everyone will tell you to clear your cache to fix. You *will* need to clear your cache, probably. Just, after fixing the MySQL connection issue.

 

The following line is to make it easier for people googling to find this post:
Fatal error: Call to a member function select() on a non-object in /public_html/app/code/community/Fishpig/Wordpress/Model/Resource/Page.php on line 119 magento fishpig

 

This post my making sure  https://xkcd.com/979/ doesn’t happen from me.

MySQL Linux CLI command execution

As another aid to my memory, you can run mysql commands on the command line like this:

mysql -u user -p[password] database -e "SELECT * FROM orders;".

 

You can also send the mysql client commands on stdin:

echo "SELECT * FROM orders" | mysql -u user -p[password] database

 

Or read them in with a file redirection

mysql -u user -p[password] database < /home/kirrus/orders.sql

That last one is really handy for reading MySQL dumps back into MySQL.

MySQL GRANT syntax oddity, show views

So that I don’t forget: Despite what the documentation says, being unclear (links always have an underscore over there, so it’s hard to tell difference between a linked underscore linked item, and one merely space-separated), you should grant ‘SHOW VIEW’, not ‘SHOW_VIEW’. Additionally, ‘SHOW VIEW’ really needs SELECT permissions as well.

Notes / MySQL Transactions

Why should you not use your notepad as a coaster? This is why:

Notes
The notes did say this, before my lovely hot black coffee destroyed them:

“begin” == Start transaction
“commit” == End transaction, saving all changes
“rollback” == Undo all changes that you’ve made in the transaction

What are they? In mySQL 5, with a table storage type of “innodb” you can use transactions. This means, that you can make a set of changes together, like recording the removal of a credit, and the adding of an advert to a website, at one instance, even if it’s multiple mysql transactions within one connection.

You do that, by sending the command (literally “BEGIN;” or “begin;”) to start a transaction, run all the queries you need to run, and then run the commit if you want the all the changes to take, or rollback if you don’t. If any one of the sql queries fails after you’ve made a begin, and it shouldn’t have, you can rollback *all* the changes you’ve made to the database. Obviously, this needs one mySQL connection, but if you’re using more than one each run of the program you’re using, I’d be very surprised.