public function &getDataGrid(IDataSourceExpression &$expression) { $rv = null; if (!$expression instanceof DbmsExpression) { throw new Exception('DbmsExpression missing'); } $db =& DbmsDataSource::getInstance($this->getDriver()); if ($rs =& $db->execute($expression->toString())) { $dgr_id = $dg_row = null; while ($row =& $rs->next()) { if (is_null($rv)) { $rv =& new DataGrid($this, $row['datagrid_id']); $rv->setTitle($row['datagrid_title']); } if ($dgr_id != $row['datagridrow_id']) { if (!is_null($dg_row)) { $rv->add($dg_row); } $dg_row =& new DataGridRow($row['datagridrow_id']); } $dg_row->add(new DataGridColumn($row['datagridcolumn_id'], $row['datagridcolumn_value'])); $dgr_id = $row['datagridrow_id']; } $rs->dispose(); } if (!is_null($dg_row)) { $rv->add($dg_row); } $db->close(); return $rv; }
public function __construct(IDataSourceDriver $driver) { parent::__construct($driver); }
System::import('System.DataSource.DbmsDataSource'); System::import('System.DataSource.DataSourceDriver'); System::import('System.Caddy.Storage.CaddyDbmsBlobStorage'); $caddy =& new Caddy(); System::export('-- adding "101-AFK" product --'); $caddy->addCaddyItem(new CaddyItem('101-AFK', 10, 1.33)); System::export($caddy, 'Caddy'); System::export('-- update "101-AFK" quantity to 5 --'); $i =& $caddy->getCaddyItem('101-AFK'); $i->setQuantity(5); System::export('-- adding features to "101-AFK" product --'); $i->addCaddyItemFeature(new CaddyItemFeature('couleur', 'Vert')); $i->addCaddyItemFeature(new CaddyItemFeature('taille', 'XL')); System::export('-- adding "AZERTY" product --'); $caddy->addCaddyItem(new CaddyItem('AZERTY', 1, 0)); $db =& DbmsDataSource::getInstance(DataSourceDriver::createNew('mysql://*****:*****@localhost.DPat/')); $db->connect(); $s =& new CaddyDbmsBlobStorage($db, $caddy); $caddyId =& $s->getCaddyId(); if (is_null($caddyId)) { $caddyId = 1; } System::export($caddyId, '-- Caddy ID --'); System::export($s->save($caddyId), '-- Save caddy to DBMS --'); System::export($caddyId, '-- Caddy ID --'); /* System::export( $s->delete( $caddyId ), '-- Delete caddy --' ); */ $caddy =& $s->loadById($caddyId); if (is_null($caddy)) { $caddy =& new Caddy();
/** * @brief Retourne une instance connecté au dbms correspondant au driver * @param $driver IDataSourceDriver driver de connexion * @return DbmsDataSource */ public static function &getInstance(IDataSourceDriver &$driver) { if (is_null(self::$_instances)) { self::$_instances = array(); } $instance_key = $driver->getDomain(); if (!array_key_exists($instance_key, self::$_instances)) { self::$_instances[$instance_key] =& self::createNew($driver); } self::$_instances[$instance_key]->connect(); return self::$_instances[$instance_key]; }