public static function instance() { if (!self::$instancia instanceof self) { self::$instancia = new self(); } return self::$instancia; }
/** * FunciĆ³n que retorna el resultado de la query en un arreglo * @return Array */ public function getArrayList() { if (is_array($this->arrayList)) { unset($this->arrayList); } $this->arrayList = array(); while ($row = MySQL_DB::instance()->DBFetchArray($this->result)) { $this->arrayList[] = $row; } return $this->arrayList; }
/** * Se debe explorar el Criteria Result para ver el tipo de objeto que retorna * @param <type> Object * @return <type> CriteriaResult */ public function find($object) { $oReflectionClass = new ReflectionClass($object); //$properties = $oReflectionClass->getProperties(ReflectionProperty::IS_PUBLIC); $properties = $oReflectionClass->getProperties(); $this->className = $class = $oReflectionClass->getName(); foreach ($properties as $key => $reflectionProperty) { $datos_where[$reflectionProperty->getName()] = $reflectionProperty->getValue($object); } $this->setList(null); $this->setObject(null); $table = $this->table = CriteriaEntityMgr::instance()->findTable($this->className); $this->SQL = MySQL_DB::instance()->DBSQLSelect($table, null, $datos_where, $this->array_order, $this->type_order); $this->execute(); $list = array(); if ($this->getNumRows() == 1) { $row = MySQL_DB::instance()->DBFetchArray($this->result); $object = $this->iterateProperty($class, $object, $row, $properties); $this->setObject($object); $list[] = $object; } if ($this->getNumRows() > 1) { while ($row = MySQL_DB::instance()->DBFetchArray($this->result)) { $object_new = $oReflectionClass->newInstance($oReflectionClass); $object_new = $this->iterateProperty($class, $object_new, $row, $properties); $list[] = $object_new; } } $this->setList($list); return $this; }
$CSLH_Config['membernum'] = ""; $CSLH_Config['offset'] = ""; $CSLH_Config['show_typing'] = ""; $CSLH_Config['webpath'] = ""; $CSLH_Config['s_webpath'] = ""; $CSLH_Config['speaklanguage'] = ""; $CSLH_Config['s_webpath'] = ""; $CSLH_Config['smtp_host'] = ""; $CSLH_Config['smtp_username'] = ""; $CSLH_Config['smtp_password'] = ""; $CSLH_Config['owner_email'] = ""; if ($installed == "true") { // CONNECT to database: if ($dbtype == "mysql") { require "class/mysql_db.php"; $mydatabase = new MySQL_DB(); // $dsn = "mysql://$datausername:$password@$server/$database"; // $mydatabase->connect($dsn); $mydatabase->connectdb($server, $datausername, $password); $mydatabase->selectdb($database); if (!$mydatabase->CONN) { // oh hell the mysql database is down. exit; } } if ($dbtype == "txt-db-api") { require "txt-db-api" . C_DIR . "txt-db-api.php"; $mydatabase = new Database("livehelp"); $dsn = "txt-db-api://{$datausername}:{$password}@{$server}/{$database}"; $mydatabase->connect($dsn); }