Example #1
0
	public function __construct($result_id, $x, $value)
	{
		try
		{
			$this->name = @mysql_field_name($result_id, $x);

			//If can't read field name			
			if (!$this->name) throw new TException(TCustomMessage::GetMessage(5008), 5008);

			$this->size = @mysql_field_len($result_id, $x);
			
			//If can't read field size
			if (!$this->size) throw new TException(TCustomMessage::GetMessage(5008), 5008);
			
			$this->type = @mysql_field_type($result_id, $x);	
			
			//If can't read field type
			if (!$this->type) throw new TException(TCustomMessage::GetMessage(5008), 5008);
			
			$this->value = $value;
			
		}
		catch (TException $e)
		{
			//...
		}
	}
Example #2
0
	public function Execute(){
		if ($this->commandtype == self::C_CMDTEXT)
		{
			//Returns a TRecordset object
			return $this->activeconnection->Execute($this->commandtext);
		}
		elseif ($this->commandtype == self::C_CMDSTOREDPROC)
		{
			try
			{				
				//Call Stored Procedure
				$this->stmt = @mssql_init($this->commandtext, $this->activeconnection->connection_id);
			
				//If can't call Stored Procedure
				if (!$this->stmt) throw new TException(TCustomMessage::GetMessage(5009, $this->commandtext), 5009);

				//Add the SQL Parameters to the Stored Procedure if it exists
				for ($x = 0; $x < $this->parameters->count; $x ++)
				{
					//Add SQL Parameter
					$k = @mssql_bind($this->stmt, $this->parameters->parameter($x)->name, &$this->parameters->parameter($x)->value, $this->parameters->parameter($x)->type,
					$this->parameters->parameter($x)->is_output, $this->parameters->parameter($x)->is_null, $this->parameters->parameter($x)->maxlen);

					//If can't add SQL Parameter
					if (!$k) throw new TException(TCustomMessage::GetMessage(5010, $this->commandtext), 5010);
				}
			
				//Execute Stored Procedure
				$this->result_id = @mssql_execute($this->stmt);	
	
				//If can't execute Stored Procedure
				if (!$this->result_id) throw new TException(TCustomMessage::GetMessage(5011, $this->commandtext), 5011);		

				//Returns a TRecordset object
				return new TRecordset($this->result_id, $this->activeconnection);
			}
			catch (TException $e)
			{
				//Set the exception
				$this->activeconnection->err = $e;
						
				//TCommand::Execute() failed, returns false 
				return false;			
			}
		}
	}