phpzend-frameworkzend-formzend-dbzend-db-table

How to execute query in Zend framework


Thanks for previous replies

I am execution "select Name from table_name where id=1"; . i saw some tutorials for getting data from the database, they mentioned $DB = new Zend_Db_Adapter_Pdo_Mysql($params); DB->setFetchMode(Zend_Db::FETCH_OBJ); and the result will getting through $result = $DB->fetchAssoc($sql); This $result is an array format, i want to get only name instead of getting all the data from the database. I am new to this topic. if i made any mistake pls do correct.


Solution

  • try this:

    $result = $DB->fetchOne("SELECT name FROM table_name WHERE id=1");