RedBeanPHP\Adapter\DBAdapter::getCell PHP Method

getCell() public method

See also: Adapter::getCell
public getCell ( $sql, $bindings = [], $noSignal = NULL )
    public function getCell($sql, $bindings = array(), $noSignal = NULL)
    {
        $this->sql = $sql;
        if (!$noSignal) {
            $this->signal('sql_exec', $this);
        }
        return $this->db->GetOne($sql, $bindings);
    }

Usage Example

Example #1
0
    /**
     * @see AQueryWriter::getKeyMapForType
     */
    protected function getKeyMapForType($type)
    {
        $databaseName = $this->adapter->getCell('SELECT DATABASE()');
        $table = $this->esc($type, TRUE);
        $keys = $this->adapter->get('
			SELECT
				information_schema.key_column_usage.constraint_name AS `name`,
				information_schema.key_column_usage.referenced_table_name AS `table`,
				information_schema.key_column_usage.column_name AS `from`,
				information_schema.key_column_usage.referenced_column_name AS `to`,
				information_schema.referential_constraints.update_rule AS `on_update`,
				information_schema.referential_constraints.delete_rule AS `on_delete`
				FROM information_schema.key_column_usage
				INNER JOIN information_schema.referential_constraints
				ON information_schema.referential_constraints.constraint_name = information_schema.key_column_usage.constraint_name
			WHERE
				information_schema.key_column_usage.table_schema = :database
				AND information_schema.referential_constraints.constraint_schema  = :database
				AND information_schema.key_column_usage.constraint_schema  = :database
				AND information_schema.key_column_usage.table_name = :table
				AND information_schema.key_column_usage.constraint_name != \'PRIMARY\'
				AND information_schema.key_column_usage.referenced_table_name IS NOT NULL
		', array(':database' => $databaseName, ':table' => $table));
        $keyInfoList = array();
        foreach ($keys as $k) {
            $label = $this->makeFKLabel($k['from'], $k['table'], $k['to']);
            $keyInfoList[$label] = array('name' => $k['name'], 'from' => $k['from'], 'table' => $k['table'], 'to' => $k['to'], 'on_update' => $k['on_update'], 'on_delete' => $k['on_delete']);
        }
        return $keyInfoList;
    }
All Usage Examples Of RedBeanPHP\Adapter\DBAdapter::getCell