I got Some Zend Message Error when Working Zend Database - zend-framework

I get the following error message:
Fatal error: Uncaught exception 'Zend_Exception' with message 'File "Zend\Db\Adapter\Mysql.php" does not exist or class "Zend_Db_Adapter_Mysql" was not found in the file' in C:\wamp\www\VPZ\Lib\Zend\Loader.php:88
Stack trace:
#0 C:\wamp\www\VPZ\Lib\Zend\Db.php(247): Zend_Loader::loadClass('Zend_Db_Adapter...')
#1 C:\wamp\www\VPZ\VPZ_Grid\core\vpz_datagrid.class.php(16): Zend_Db::factory('mysql')
#2 C:\wamp\www\vpz_test.php(9): VPZ_DataGrid->ConnectDb(Object(VPZ_Connector))
#3 {main} thrown in C:\wamp\www\VPZ\Lib\Zend\Loader.php on line 88
I dont know what about this and find directory in "Zend\Db\Adapter\Mysql.php" not have but have Mysqli.php

you are trying to create a Zend_Db object with MySQL adapter, I think. there is no MySQL adapter by default for Zend Framework. you should use MySQLi adapter, or Pdo_Mysql.
checkout your code, where you are creating your Zend_Db object. pass in 'Pdo_Mysql' as your adapter name, instead of 'Mysql':
$_db = Zend_Db::factory('Mysql', $configArray );
// uses mysql adapter, which is not available by default.
$_db1 = Zend_Db::factory('Mysqli', $configArray );
// uses mysqli adapter, but needs php_mysqli extension to be installed.
$_db1 = Zend_Db::factory('Pdo_Mysql', $configArray );
// uses PDO mysql adapter which is much better, but needs PDO to be installed, which most of times is installed.
you can write your own adapter for Zend_Db. write a class and extend the Zend_Db_Adapter_Abstract. but there are some problems to implement Mysql adapter, because PHP_MySQL extension (that will provide PHP with mysql_* functions) does not support many features (like client stored procedures, ...). so you can not implement all of methods that other Zend_Db_Adapters have. I've done this before. I wanted to use my application, that used Zend Framework, and I hosted it on a server that PDO and Mysqli were not installed. I implemented a Mysql adapter for Zend_Db, but because I knew which methods are not implemented, I avoided calling those.
the best thing is if you could have PDO installed, and use Pdo_* adapters.

Related

Uncaught TYPO3 Exception: Cannot use object of type __PHP_Incomplete_Class as array

Core: Exception handler (WEB): Uncaught TYPO3 Exception: Cannot use object of type __PHP_Incomplete_Class as array | Error thrown in file typo3/sysext/backend/Classes/Controller/Page/TreeController.php in line 189
This happened after a core update to TYPO3 - 9.5.17
https://forge.typo3.org/issues/91407
The following thanks to Michael Hitzler.
As far as I can see there is already a solution within the install tool in class BackendUserConfigurationUpdate.
This seems to address exactly the issue.
Not quite sure in which version the additional migration task has been added, but it helps you solving the issue system wide.
Just got to module Admin Tools -> Update and select Update Wizard.
There you should see a new, not yet executed migragtion task:
Update backend user configuration array
The backend user "uc" array, which is persisted in the db, now only allows for arrays inside its structure instead of stdClass objects. Update the uc structure for all backend users.
Execute this migration task and your BE users will be updated and have a sane uc configuration in the end.
Problem solved and page tree can be loaeded again.
./typo3cms upgrade:wizard backendUsersConfiguration
Should solve the issue.

Why I get 500 Error while on XAMPP while loading CodeIgniter 3 database library?

I have gone through number of threads on stackoverflow and on other forums to find the answer but could not find relevant answer. People have applied different approaches but none has worked for me thus far.
I am using CI 3 on XAMPP and whenever I load database library in the model, I run into 500 Error.
Here is my CI database config info:
'hostname' => 'localhost',
'username' => 'my_user',
'password' => 'my_pass',
'database' => 'prod_db',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
PHP ini db libraries are as below:
extension=php_bz2.dll
extension=php_curl.dll
extension=php_fileinfo.dll
;extension=php_ftp.dll
extension=php_gd2.dll
extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_intl.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
extension=php_mbstring.dll
extension=php_exif.dll ; Must be after mbstring as it depends on it
extension=php_mysqli.dll
;extension=php_oci8_12c.dll ; Use with Oracle Database 12c Instant Client
;extension=php_openssl.dll
;extension=php_pdo_firebird.dll
extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
;extension=php_pgsql.dll
;extension=php_shmop.dll
; The MIBS data available in the PHP distribution must be installed.
; See http://www.php.net/manual/en/snmp.installation.php
;extension=php_snmp.dll
My model code is as below:
class loginmodel extends CI_Model {
public function validate_login($username, $password) {
$this->load->database();
$var = 0;
return $var;
}
}
Whenever I remove $this->load->database(); from the model, my code runs and i am able to redirect to a "Login Failed" page. BUT, whenever I load my database library in autoload.php or load it in above model, code fails.
Autoload.php
$autoload['libraries'] = array('database');
Apache error logs showed below errors but I could not figure as why this was happening.
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\php\\ext\\php_mysqli.dll' - The specified module could not be found.\r\n in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\php\\ext\\php_pdo_mysql.dll' - The specified module could not be found.\r\n in Unknown on line 0
Please advise.
EDIT:
I verified all config to be OK and as stated in the comments, I added environment variables to windows and verified through PHPInfo that mysqli and mysqlnd were loaded.
Despite getting all the config right, error still persisted and I did a clean install of CI to reproduce library load failure. This time CI returned an error that db access was denied.
I then realized that after migration, database user was not created in the new environment. So once I created the desired user and assigned it required privileges, I was able to run the code just fine.
Therefore, if anyone encounters such issue in future, below steps might help:
First and foremost, verify if your desired user can access the
database.
Modify your .htaccess to use your desired URL schemes only after
verifying that database connection is working
Then verify that absolute path is available in PHP.ini on XAMPP.
Plus, verify that PHP is added in the environment variables. My
Values on Windows 10 are as follows: Variable Name: PHP , Variable
Value: C:\xampp\php\ext
In CI, mysqli is selected as database driver
In PHP.ini mysqli extension is enabled. i.e. php_mysqli.dll
Echo PHPInfo to verify that mysqli and mysqlnd are available in your
installation.
If nothing works, do a clean install of CI on a separate directory and load database library after setting up your database configuration and before setting up .htaccess until you can reproduce the error.
Hope that error will be eliminated!

getSchema in PostgreSQL JDBC driver throws java.lang.AbstractMethodError or java.sql.SQLFeatureNotSupportedException

I'm using Postgresql 8.4 and my application is trying to connect to the database.
I've registered the driver:
DriverManager.registerDriver(new org.postgresql.Driver());
and then trying the connection:
db = DriverManager.getConnection(database_url);
(btw, my jdbc string is something like: jdbc:postgresql://localhost:5432/myschema?user=myuser&password=mypassword)
I've tried various version of the jdbc driver and getting two type of errors:
with jdbc3:
Exception in thread "main" java.lang.AbstractMethodError: org.postgresql.jdbc3.Jdbc3Connection.getSchema()Ljava/lang/String;
with jdbc4:
java.sql.SQLFeatureNotSupportedException: Il metodo ½org.postgresql.jdbc4.Jdbc4Connection.getSchema()╗ non Þ stato ancora implementato.
that means: method org.postgresql.jdbc4.Jdbc4Connection.getSchema() not implemented yet.
I'm missing something but I don't know what..
------ SOLVED ---------
The problem were not in the connection String or the Driver version, the problem were in the code directly above the getConnection() method:
db = DriverManager.getConnection(database_url);
LOGGER.info("Connected to : " + db.getCatalog() + " - " + db.getSchema());
It seems postgresql driver doesn't have getSchema method, as the java console were often trying to say to me..
The Connection.getSchema() version was added in Java 7 / JDBC 4.1. This means that it is not necessarily available in a JDBC 3 or 4 driver (although if an implementation exists, it will get called).
If you use a JDBC 3 (Java 4/5) driver or a JDBC 4 (Java 6) driver in Java 7 or higher it is entirely possible that you receive a java.lang.AbstractMethodError when calling getSchema if it does not exist in the implementation. Java provides a form of forward compatibility for classes implementing an interface.
If new methods are added to an interface, classes that do not have these methods and were - for example - compiled against an older version of the interface, can still be loaded and used provided the new methods are not called. Missing methods will be stubbed by code that simply throws an AbstractMethodError. On the other hand: if a method getSchema had been implemented and the signature was compatible that method would now be accessible through the interface, even though the method did not exist in the interface at compile time.
In March 2011, the driver was updated so it could be compiled on Java 7 (JDBC 4.1), this happened by stubbing the new JDBC 4.1 methods with an implementation that throws a java.sql.SQLFeatureNotSupportedException, including the implementation of Connection.getSchema. This code is still in the current PostgreSQL JDBC driver version 9.3-1102. Technically a JDBC-compliant driver is not allowed to throw SQLFeatureNotSupportedException unless the API documentation or JDBC specification explicitly allows it (which it doesn't for getSchema).
However the current code on github does provide an implementation since April this year. You might want to consider compiling your own version, or ask on the pgsql-jdbc mailinglist if there are recent snapshots available (the snapshots link on http://jdbc.postgresql.org/ shows rather old versions).

symfony2 php codesniffer standard error

I'm new to phpCodeSniffer and I'm trying to integrate it with eclipse. I've downloaded phpCodeSniffer from PEAR following these instructions, and I also downloaded Symfony2 standards from Github and the php-cs-fixer. I followed all the instructions and everything works fine, but when I try to use the sniffer with eclipse I get the following error:
/usr/bin/php -c /tmp/zend_debug/session7507717624755069136.tmp -d asp_tags=off -d short_open_tag=on /opt/eclipse/plugins/org.phpsrc.eclipse.pti.tools.codesniffer_1.3.0.R20111119000000/php/tools/phpcs.php --report=xml --standard=/usr/share/php/PHP/CodeSniffer/Standards/Symfony2 --tab-width=4 /var/www/siga-nuevo/src/Siga/UserBundle/Controller/UserController.php
PHP Fatal error: Uncaught exception 'PHP_CodeSniffer_Exception' with message 'Referenced sniff Symfony2.Commenting.FunctionComment.MissingParamComment does not exist' in /opt/eclipse/plugins/org.phpsrc.eclipse.pti.library.pear_1.2.2.R20120127000000/php/library/PEAR/PHP/CodeSniffer.php:814
Stack trace:
0 /opt/eclipse/plugins/org.phpsrc.eclipse.pti.library.pear_1.2.2.R20120127000000/php/library/PEAR/PHP/CodeSniffer.php(730): PHP_CodeSniffer->_expandRulesetReference(Object(SimpleXMLElement))
1 /opt/eclipse/plugins/org.phpsrc.eclipse.pti.library.pear_1.2.2.R20120127000000/php/library/PEAR/PHP/CodeSniffer.php(623): PHP_CodeSniffer->getSniffFiles('/usr/share/php/...', 'Symfony2')
2 /opt/eclipse/plugins/org.phpsrc.eclipse.pti.library.pear_1.2.2.R20120127000000/php/library/PEAR/PHP/CodeSniffer.php(438): PHP_CodeSniffer->setTokenListeners('/usr/share/php/...', Array)
3 /opt/eclipse/plugins/org.phpsrc.eclipse.pti.library.pear_1.2.2.R20120127000000/php/library/PEAR/PHP/CodeSniffer/CLI.php(551): PHP_CodeSniffer->process(Array, '/usr/ in /opt/eclipse/plugins/org.phpsrc.eclipse.pti.library.pear_1.2.2.R20120127000000/php/library/PEAR/PHP/CodeSniffer.php on line 814
This is my eclipse configuration:
It looks like the OpenSky symfony2 standards are broken in your case. The relevant part of the error message is this one:
Uncaught exception 'PHP_CodeSniffer_Exception' with message 'Referenced sniff Symfony2.Commenting.FunctionComment.MissingParamComment does not exist'
As symfony follows all the current PSR standards - namely the PSR-0, PSR-1, PSR-2 and PSR-3 (of which PSR-3 provides just the logger interface which monolog respects).
You can aswell directly use the PSR-2 standard included with newer Versions of PHPCS.
The PSR-2 standard implementation in PHPCS has been updated recently - opposite to those old symfony2 standards. Which means the implementation should be more accurate anyway.

Undefined method `FactoryGirl' -- upgrading from 2.0.2 to 3.4.2

I'm in the process of upgrading from factory_girl (2.0.2 to 3.4.2) and factory_girl_rails (1.1.0 -> 3.4.0)
and I'm having issues with my rspec tests seeing factory girl.
I think I've successfully altered my factories to deal with the new syntax, and have removed the extra require statements that were bringing in multiple copies of the same files. My server now starts up, so I know that the factories.rb file is correctly getting parsed.
Now when I run my rspec tests, I'm getting this error:
NoMethodError: undefined method `FactoryGirl' for #
it 'can be created' do
course = FactoryGirl(:course)
….
end
With Factory Girl 3.4.2, you will need to explicitly use the create method.
course = FactoryGirl.create(:course)