Posts Tagged Zend Framework

MS SQL Server 2008 connection from ZF problem? SOLVED

If you have message like ‘General error: 20018 Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier.’ probably one of your columns is invalid.

In my scenario i had one column nvarchar(max).

Solution to that problem is to build query using CAST f.e.:
‘synopsis’ => new Zend_Db_Expr(‘CAST(synopsis AS nvarchar(4000))’),

Tags: , , , ,

Use PHP and PDO to connect to MS SQL Server (Zend Framework)

Problems connecting to MS SQL server from Zend Framework?

Message: The mssql driver is not currently installed

Solution is simple

Install pdo_mssql driver: (Ubuntu)

#sudo apt-get install php5-sybase
#sudo /etc/init.d/apache2 restart

On Centos you need to install pdo_dblib (any problems check here)

It will not reflect in phpinfo() page

Trick is to setup connection properly:

$dbAdapter = new Zend_Db_Adapter_Pdo_Mssql(array(
 'host'     => '192.xxx.xxx.xxx', // parklife
 'username' => 'xxx',
 'password' => 'xxx',
 'dbname'   => 'xxx',
'pdoType'  =>  'dblib' )
 );

Tags: , , ,

Zend_db_table how to find row by multiple columns?

Maybe should dig more in ZF API, but found simple solution:


class YourClass extends Zend_Db_Table_Abstract
{

public function findOneByParams(array $params)
{
// prepare query
$query = $this->select();

// add our terms
foreach ($params as $param => $value)
{
$query->where($param.' = ?', $value);
}

// find row
$row = $this->fetchRow($query);

// return
return $row;
}
}

Tags: , ,

Zend Framework on-line tutorials/documentation

Last time I was using ZF when it was something around 1.5, so I was quite shocked when downloaded version 1.7 and started to use it.

Documentation is quite ok, when you know what you want to do, but of course it is better when someone else will explain.
Found nice knowledge resource – http://robertbasic.com/blog/online-resources-for-zend-framework/

Tags:

HTML code in Zend Forms description

If you want to use HTML as description in Zend Forms use :

$name = new Zend_Form_Element_Text('fullname'); $name-&gt;setLabel('Full name:'); $name-&gt;setDescription('<a class="thickbox" title="Please choose customer" href="/customers/indexajax?KeepThis=true&amp;TB_iframe=true&amp;height=600&amp;width=1100">Find customer</a>');

Tags: , , ,